152
votes
Accepted
How do I jump to the location of my last edit?
The `. command will bring you to your last change.
The ` goes to a mark, and . is a "special" mark which is automatically set to the position where the last change was made. See :help `. for some ...
144
votes
Accepted
How do I navigate to topics in Vim's documentation?
Vim comes with an exhaustive and fully indexed documentation that contains the answers to most of the questions you may have on using Vim.
But the documentation is huge and may look to the neophyte ...
72
votes
Accepted
Why is using arrow keys in normal mode considered bad practice?
Actually this is not a bad practice.
A lot of people (including Vim's doc as @B Layer's answer shows) argue that you shall not use arrow keys because it makes your hands move from the home row (the ...
58
votes
Accepted
How to jump between matching HTML/XML tags?
Vim ships with a macro called matchit that does this for you; all you need to do is activate it with runtime macros/matchit.vim in your vimrc. This will enable you to jump from, eg, a <div> to ...
51
votes
Accepted
How can I jump to the next "paragraph"?
Yes, you can use the } and { paragraph motions to move a paragraph forwards or backwards.
From :help paragraph:
A paragraph begins after each empty line, and also at each of a set of
paragraph ...
48
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
How to jump between matching HTML/XML tags?
You can jump between tags using visual operators, for example:
Place the cursor on the tag.
Enter visual mode by pressing v.
Select the outer tag block by pressing a+t or i+t for inner tag block.
...
46
votes
Accepted
How can I move the cursor to the top or bottom of the screen?
Type H (capital H, H for "high") to move to the top of the screen.
Type L (capital L, L for "low") to move to the bottom of the screen.
44
votes
Accepted
Can I delete an entire line, except the line break?
You can use 0D this will go to the first character on the line and delete until the end of the line. Note that you can use ^D if you want to leave any preceding whitespace alone. Also, these ...
41
votes
Why is using arrow keys in normal mode considered bad practice?
I don't know if this is really relevant any more, but I'm an old-timer so here's a bit of history.
In the old days, VT100 terminals had arrow keys, but pressing one transmitted an escape sequence ...
38
votes
Accepted
How can I get ‘n’ to go forward even if I started searching with ‘?’ or ‘#’?
You can change the behaviour of n and N to search consistently downwards/upwards by useing the following:
nnoremap <expr> n 'Nn'[v:searchforward]
nnoremap <expr> N 'nN'[v:searchforward]
...
38
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 ]).
36
votes
Accepted
How to delete line above/below cursor, but not current line?
:-d
cuts the line above the current line.
:-5d
cuts the 5th line above the current line (but moves the cursor).
:-5,-d
cuts the 5 lines above the current line.
:+,+5d
cuts the 5 lines below the ...
31
votes
Accepted
How do I deal with very long lines in text (500+ characters)?
You can use g series of commands to move to the boundaries of the visible screen area. For example, g$ moves to the right edge of the screen (which is not necessarily the end of the line). gj moves ...
31
votes
How do I jump to the location of my last edit?
Here's another approach that fits your given scenario, and will jump to where you were immediately prior to the gg (not to the last changed line).
Use CtrlO
When you press gg, your old cursor ...
30
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 ...
30
votes
Why is using arrow keys in normal mode considered bad practice?
While I agree with @statox that no one should be chastised, shunned, excommunicated, or tarred-and-feathered if they choose to use the arrow keys...use your software however you see fit...I wouldn't ...
28
votes
How do I jump to the location of my last edit?
To add to dnetserr's answer and Peter Rincker's comment, Vim maintains a list of changes, and has some commands associated with this.
:changes
will list the changes, showing you where they were and ...
28
votes
Accepted
How to restore the position of the cursor after executing a normal command?
You should use getpos():
To save you position in a variable:
let save_pos = getpos(".")
getpos() takes as argument a mark, here "." represents the current position of your cursor.
And to restore ...
28
votes
Accepted
Scroll a quarter (25%) of the screen up or down
Maybe ctrld and ctrlu could be what you are looking for. By default they move half of the screen.
From :h CTRL-D:
Scroll window Downwards in the buffer. The number of
lines comes from the '...
27
votes
Accepted
Why can ci" be outside of quoted area and ci( only works inside parentheses?
The main difference here is that parenthetical statements (targeted by ci() can be nested, while quoted strings (targeted by ci") cannot.
If your cursor is outside of some parenthetical statement, it ...
26
votes
Accepted
Jumping to a byte offset, and displaying position as byte offset
:goto 2356
jumps to the 2356th byte in the buffer.
Use the %o field in 'statusline' or 'rulerformat' to display the byte number of the character under your cursor.
Use %O to display the value in ...
26
votes
Accepted
How to replace inner text with yanked text
You can use vi"p when inside "". This can replace text in yank register, so it matters when you want to use original yanked text more than once.
EDIT:
Additional info from Octaviour comment regarding ...
24
votes
Can I delete an entire line, except the line break?
cc <Esc> will do as you ask, but is more keystrokes than 0D. If you want to put something into that line afterwards, cc may be best.
23
votes
Accepted
How do I make Vim always display several lines after EOF?
You can use ctrlE to scroll down your file, when you are at the end of the file it will add "virtual" line so the last line of the file is not at the bottom of the windows.
Additionally you can use ...
23
votes
Accepted
How to go to end/get out of the parenthesis of a line in vim?
I'm not 100% clear if this is what you're asking, but I think you might be looking for:
])
This jumps to the nearest enclosing ). So if your cursor was on the / in the below:
(2 / (3 + 5) * 9)
^...
22
votes
22
votes
Accepted
How can I use a line number to copy a line to where my cursor is?
Looks like a case for ex copy (:help :co or :help :t):
:1t4
or, using your cursor's position:
:1t.
This does not copy the line to the yank register, which might or might not be what you want.
21
votes
21
votes
Edit different words simultaneously, one the same line like in Sublime Text with multiplie selections
In Vim there are no multi-cursors like in Sublime Text (but there are some plugins as I remember). But it seeems not so important stuff for vim because there is another way to achieve this. For ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
cursor-movement × 275key-bindings × 42
cursor-motions × 39
normal-mode × 23
vimscript × 20
cursor × 14
vimrc × 12
search × 12
cut-copy-paste × 11
insert-mode × 11
scrolling × 11
indentation × 9
visual-mode × 6
jumplist × 6
count × 5
find × 5
gvim × 4
autocmd × 4
substitute × 4
folding × 4
macro × 4
wrapping × 4
navigation × 4
whitespace × 4
neovim × 3