85
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 ...
49
votes
How to disable arrow keys in vim?
In case you, or someone else reading this topic, just wants to disable the key movements without the text warning enter the following lines in .vimrc
noremap <Up> <Nop>
noremap <Down&...
46
votes
Accepted
Multiple cursors at desired location
Using multiple cursor isn't a Vimmer thing
As I said in the comments using multi cursors (even with a plugin) isn't really "following the Vim way", I totally understand that it is attractive for ...
42
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 ]).
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 ...
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%
32
votes
Accepted
How to disable arrow keys in vim?
You can install the hardmode plugin and in your .vimrc put in
let g:HardMode_level = 'wannabe'
let g:HardMode_hardmodeMsg = 'Don''t use this!'
autocmd VimEnter,BufNewFile,BufReadPost * silent! call ...
27
votes
Accepted
Why do `cw` and `ce` do the same thing?
It's a special case. Check the documentation for WORD, under "Special case":
Special case: "cw" and "cW" are treated like "ce" and "cE" if the cursor is on a non-blank. This is because "cw" is ...
27
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 ...
25
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
[] ...
23
votes
Accepted
How to treat underscores like space?
dw deletes a word, and what constitutes a word is defined by the iskeyword setting. From :h word:
word
A word consists of a sequence of letters,...
23
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-...
21
votes
Accepted
How to quickly add content in a new line at end of file?
If file is already opened in normal mode
Use:
Go
G goes to the end of the file
o enters insert mode on a line below the current one
If you are opening the file from the command line
You can open ...
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"
...
17
votes
Accepted
Is there a text object for current line?
Here are crude "line" text objects:
xnoremap il g_o0
onoremap il :normal vil<CR>
xnoremap al $o0
onoremap al :normal val<CR>
And a crude "buffer" text object:
xnoremap ...
17
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 ...
16
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 <...
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 "[" ...
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 ...
14
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 ...
13
votes
How to delete till the end of the previous line (i.e. to end of line above)?
Well, you can combine the "backward search" motion and the delete operator:
d?$<Enter>
13
votes
Accepted
How to delete till the end of the previous line (i.e. to end of line above)?
Try d0kJx
Deletes backwards to the beginning of the line, moves up, then joins the two lines and then removes the space in between the two joined lines.
You don't have to leave normal mode with this....
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 ...
13
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 ...
12
votes
Grok Vim motions and simple edits
When editing text, I find the Emacs commands of Alt-F, Alt-B, Ctrl-a, Ctrl-e, Alt-D and Alt-Backspace to be very useful and intuitive, allowing for quick and easy local edits while working with text (...
12
votes
Accepted
Mapping with motion
vim supports operator-mapping :h map-operator.
What you need is an operatorfunc, and a mapping. for your needs, the followings codes work. Well it is just an example, you refine further.
nmap <...
12
votes
Accepted
How do I surround a quoted string without including leading whitespace?
It's not specific to vim-surround - va' also selects the leading whitespace. From :h a':
a" v_aquote aquote
a' ...
11
votes
Accepted
How to keep in the undo history just one change for this command?
I think you are interested in :h undo-blocks.
To make the long command, e.g. d0kJx, undoable as a single change, you can run it from the command line through normal, e.g.:
:normal! d0kJx
Here the ! ...
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 ...
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 ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
cursor-motions × 250cursor-movement × 42
key-bindings × 38
normal-mode × 23
cut-copy-paste × 20
visual-mode × 20
object-motions × 18
vimscript × 15
custom-text-object × 12
neovim × 10
vimrc × 9
cursor × 9
search × 7
replace × 7
insert-mode × 5
ex-mode × 5
map-operator × 5
indentation × 4
functions × 4
filetype-tex × 4
repeated-commands × 4
count × 4
substitute × 3
highlight × 3
folding × 3