Skip to main content
Share Your Experience: Take the 2024 Developer Survey
86 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.1k
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.1k
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,780
28 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.7k
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.7k
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,222
18 votes
Accepted

Why does "Operator" + "Motion" behave inconsistently?

From :h operator After applying the operator the cursor is mostly left at the start of the text that was operated upon. For example, "yfe" doesn't move the cursor, but "yFe" ...
Tommy A's user avatar
  • 6,790
18 votes
Accepted

Is it possible to have Vim displaying the list of available marks when using marks?

You can define a very simple custom mapping that lists the available marks and pre-populates the command-line with the right command stub, ready for you to type the desired mark name: nnoremap <...
romainl's user avatar
  • 41.1k
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,780
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
  • 29k
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,756
14 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.1k
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

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.7k
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
  • 29k
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
Accepted

Why doesn't n jump to the last character matched with f?

You confused nwhich repeat the last search (made via / or ?) and ; which allows to repeat the last f, F, t or T movement. As a bonus n and ; go forward while N and , go backward. See :h n and :h ; ...
statox's user avatar
  • 50.1k
10 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,756
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.7k
9 votes
Accepted

How can I print out the iskeyword characters?

You can use: :echo map(range(48, 57), 'nr2char(v:val)') :echo map(range(192, 255), 'nr2char(v:val)') Which should output: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'] ['À', 'Á', 'Â', '...
Martin Tournoij's user avatar
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.1k
9 votes
Accepted

What does vim consider a paragragh?

You may want to move to the next section: ]] Documentation: :h paragraph A paragraph begins after each empty line, and also at each of a set of paragraph macros, specified by the pairs of ...
nobe4's user avatar
  • 16.1k
9 votes
Accepted

Jump to next identifier in Vim help files

In the help files the identifiers are actually marked as |identifier| (but you don't see the | because of the syntax file, use set ft=txt in an help buffer to check what I'm talking about). You could ...
statox's user avatar
  • 50.1k
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.7k
8 votes
Accepted

Change/delete matching brackets at the same time

Surround does what you want and more: ds( delete first surrounding pair of parentheses 2ds( delete second surrounding pair of parentheses cs[{ change surrounding pair of square brackets into a ...
romainl's user avatar
  • 41.1k

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