Last call to make your voice heard! Our 2022 Developer Survey closes in less than a week. Take survey.
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 ...
user avatar
  • 1,648
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 ...
user avatar
  • 32.6k
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 ...
user avatar
  • 45.9k
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 ...
user avatar
  • 1,200
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 ...
user avatar
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&...
user avatar
  • 581
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. ...
user avatar
  • 16.5k
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.
user avatar
  • 8,739
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 ...
user avatar
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 ...
user avatar
  • 511
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] ...
user avatar
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 ]).
user avatar
  • 1,111
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 ...
user avatar
  • 32.6k
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 ...
user avatar
  • 8,739
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 ...
user avatar
  • 2,517
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 ...
user avatar
  • 654
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 ...
user avatar
  • 18.1k
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 ...
user avatar
  • 7,992
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 ...
user avatar
  • 45.9k
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 '...
user avatar
  • 45.9k
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 ...
user avatar
  • 7,140
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 ...
user avatar
  • 32.6k
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 ...
user avatar
  • 4,208
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.
user avatar
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 ...
user avatar
  • 45.9k
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) ^...
user avatar
  • 27.4k
22 votes

How do I move the cursor to the center of current line?

The built-in gm does exactly this.
user avatar
  • 7,140
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.
user avatar
  • 1,205
21 votes

How do I jump to the location of my last edit?

g; will go to the previously edited line.
user avatar
  • 209
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 ...
user avatar

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