Skip to main content
87 votes
Accepted

Why does vim use hjkl for cursor keys?

From http://www.catonmat.net/blog/why-vim-uses-hjkl-as-arrow-keys/: When Bill Joy created the vi text editor he used the ADM-3A terminal, which had the arrows on hjkl keys. Naturally he reused the ...
nobe4's user avatar
  • 16.2k
45 votes
Accepted

Delete until the right end of the current inner block

I would use d]) which means delete (d) to the next unmatched ')' (])). See :help ]).
ryuichiro's user avatar
  • 1,171
35 votes
Accepted

Simplest way to delete a "composite" word?

What you are calling a composite word is actually a WORD (by opposition to a word). Reading :h word and :h WORD should be helpful: *word* A word consists of a sequence of ...
statox's user avatar
  • 50.4k
34 votes
Accepted

How to jump to middle of buffer

You can use N% to jump to the Nth percent of the file. So e.g. 50% jumps roughly to the middle of the buffer. See the help at :h N%
Christian Brabandt's user avatar
29 votes
Accepted

End of python block motion

With the update from November 2017 of $VIMRUNTIME/ftplugin/python.vim following ft-specific motions are available for the python language [[ Jump backwards to begin of current/previous toplevel [] ...
Hotschke's user avatar
  • 4,830
29 votes

Why does vim use hjkl for cursor keys?

Nobe4's answer is great, and explains why we use hjkl very well. However, it's really interesting to see the full keyboard, and a lot of strange things about vim make more sense when you can see the ...
DJMcMayhem's user avatar
  • 17.8k
24 votes
Accepted

Why is the underscore command _ useful?

Good question! As a motion by itself, you're right, _ is not a particularly useful key. :h _ *_* _ <underscore> [count] - 1 lines downward, on the first non-...
DJMcMayhem's user avatar
  • 17.8k
19 votes

Why does vim use hjkl for cursor keys?

As to why these arrows were printed on these keys... it's because they could be used with the control key for local cursor movement. Ctrl-H and Ctrl-J (backspace and line feed) are obvious, and an ...
Random832's user avatar
  • 1,232
16 votes
Accepted

How to delete entire function definition (C style)

Motion ][: next } in the first column V][d does what you want. More details can be found under :h ][ and :h section: *section* [...] The "]" and "[" ...
Hotschke's user avatar
  • 4,830
16 votes
Accepted

Vim normal mode: why is j/k jumping paragraphs instead of lines?

Vim is not really jumping paragraphs... These are actually really long lines. The default behavior is for Vim to wrap long lines, so they might end up taking multiple lines in your screen, but they're ...
filbranden's user avatar
  • 29.6k
15 votes
Accepted

Which text object defines text enclosed in space?

I believe you are looking for the WORD text object. From :h WORD: A WORD consists of a sequence of non-blank characters, separated with white space. An empty line is also considered to be a ...
Tumbler41's user avatar
  • 7,786
15 votes
Accepted

Key binding to select the current paragraph

See: :h ip :h ap You are looking for the built in vip. Also, :h text-objects is a good start to find the text objects you are looking for. Edit To address your comment: to move the cursor to one ...
statox's user avatar
  • 50.4k
13 votes
Accepted

Why does >3k move the cursor up when >3j does not move it down?

Yes, Vim automatically moves to the top most indented line. To see this, position the cursor in the middle of a paragraph and use >ap to indent the whole paragraph. Note that this is not specific ...
Lithis's user avatar
  • 1,040
11 votes

Why do `cw` and `ce` do the same thing?

The difference between the behavior of the motion in cw vs. dw can be explained simply: normally if you want to change a word you're going to leave the whitespace following it, while deleting a word ...
dash-tom-bang's user avatar
11 votes
Accepted

How to select the content within brackets including brackets and without including brackets?

You can use text objects to accomplish this. Start a selection with v and then: For selecting inside use: i{ For selecting the whole block including braces use: a{ You can also do this with any ...
Tumbler41's user avatar
  • 7,786
11 votes

Why does "e" move you one character before the actual end of the word?

This is assuming that your setup is using the ordinary e. If this doesn't answer your question, check if e is mapped to anything with :nmap e This comes from a fundamental misunderstanding of where ...
DJMcMayhem's user avatar
  • 17.8k
11 votes

Simplest way to delete a "composite" word?

Another more general solution is to delete up to the whitespace character using dt (with a space after the t), which means "delete to [character]. This often is useful for things like dt: and similar ...
allo's user avatar
  • 231
11 votes
Accepted

How to go back to the start of a visual selection?

You can use the o visual-mode command to jump to the "other" end of the visual selection.
filbranden's user avatar
  • 29.6k
11 votes
Accepted

How to append to the end of word with one key stroke?

object_name = "foo" another_long_object_name = "bar" again_different_length_word_which_needs_same_modification = "spam" I would like to press a keystroke when standing ...
JoL's user avatar
  • 570
10 votes

A version of `w` which skips to the next underscore

This can be done very easily with the iskeyword option. From :h iskeyword *'iskeyword'* *'isk'* 'iskeyword' 'isk' string (Vim default for MS-DOS and Win32: ...
DJMcMayhem's user avatar
  • 17.8k
9 votes

Multiple cursors at desired location

More Vim ways. First task: \section[foobar baz]{foobar baz} Workflow: \section[]{} hh ifoobar baz<Esc> $. Second task: variable1 = 2 my_variable2 = 12 var3 = 14 Command: 3:norm ...
romainl's user avatar
  • 41.8k
8 votes

How to disable arrow keys in vim?

You could add this to your .vimrc to disable the arrow keys in Command, Insert, Normal and Visual Mode: " Remove newbie crutches in Command Mode cnoremap <Down> <Nop> cnoremap <Left>...
NonlinearFruit's user avatar
8 votes

Why can ci" be outside of quoted area and ci( only works inside parentheses?

The other answers covered why this happens. Here's a nice way to work around it. wellle/targets.vim. I just recently found this plugin, and I think it's extremely underrated. It provides a new text ...
DJMcMayhem's user avatar
  • 17.8k
8 votes

truncate sentence: delete up to, but not including period

t and f are nice when we are on the same line. If the period is on another line, we're back to /\.. If you want to type ds, or cs, or ys, ... it can be done thanks to an operator-pending mode mapping: ...
Luc Hermitte's user avatar
  • 17.7k
8 votes

How to use 'w' to navigate in CamelCase words?

This is not how w and iskeyword works. Consider this example: !his!s!!hort!entence ^^ ^^^ ^ ^^ Pressing w repeatedly, you will see the cursor stops where sequences of !s meet sequences of alpha ...
Mass's user avatar
  • 14.2k
8 votes
Accepted

Delete to next search result?

this can be done with d/term<cr>
Naumann's user avatar
  • 2,769
8 votes
Accepted

Unable to set iskeyword for colon ( : ) character

You are looking for set iskeyword-=: That is, making : explicitly not a keyword character. If : is in iskeyword it will be included in ciw.
Mass's user avatar
  • 14.2k
8 votes
Accepted

Why does `yW` yank until the end of the WORD, but `W` move to the next one?

It might be useful to quote :help exclusive, here: A character motion is either inclusive or exclusive. When inclusive, the start and end position of the motion are included in the operation. When ...
romainl's user avatar
  • 41.8k
7 votes

How to disable arrow keys in vim?

This is how I do it, I call it hard_ass.vim for key in ['<Up>', '<Down>', '<Left>', '<Right>'] exec 'noremap' key '<Nop>' exec 'inoremap' key '<Nop>' exec '...
Dhruva Sagar's user avatar
  • 5,560
7 votes
Accepted

Delete to ; if exists, otherwise to end of line

This should do the trick for you: nnoremap <buffer> <expr> C (getline('.')[getpos('.')[2]:] =~ ';')? "ct;" : "c$" <expr> allows us to do conditional mapping getline('.') =~ ';' ...
Tumbler41's user avatar
  • 7,786

Only top scored, non community-wiki answers of a minimum length are eligible