Skip to main content
73 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 ...
statox's user avatar
  • 50.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
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 ...
dwilliss's user avatar
  • 511
33 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 '...
statox's user avatar
  • 50.2k
31 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 ...
statox's user avatar
  • 50.2k
31 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 ...
grodzik's user avatar
  • 4,658
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 ...
B Layer's user avatar
  • 20k
28 votes
Accepted

Go to column number?

Just type 80| -> :h | This is perfect for interactive mode. When scripting, there are other ways.
Luc Hermitte's user avatar
  • 17.6k
27 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 ...
statox's user avatar
  • 50.2k
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) ^...
Rich's user avatar
  • 32.3k
16 votes
Accepted

Move inside next quotes?

f" jumps to the next quote, and F" jumps to the previous one. 3f" jumps three more quotes, and so on. This seems enough to me. If the cursor is inside the quote, and you want to jump to the position ...
Violapterin's user avatar
16 votes

Why is using arrow keys in normal mode considered bad practice?

Other answers have said that the efficiency loss from moving your hands from the home row isn't that big a deal, and I mostly agree. However, what is a big deal is when you are learning vim, always ...
Karl Bielefeldt's user avatar
14 votes

Moving to an outer block

[% and ]% provided by matchit or match-up The answer by Mass suggesting [{ and ]} works perfectly for unmatched curly brackets but only for curly brackets. This should be considered as an advantage. ...
Hotschke's user avatar
  • 4,800
13 votes

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

Saving a character on the accepted answer: gi Will take the cursor to the exact point last edited and put you in insert mode, ready to continue typing. (It's also quicker to type!)
Noel Evans's user avatar
13 votes
Accepted

Percent key ( % ) matching behavior for angle brackets ( < > )

'matchpairs' controls what characters form pairs which % will work upon. You can add angle brackets by doing the following command as suggested by :h 'matchpairs': :set matchpairs+=<:> Since '...
Peter Rincker's user avatar
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
13 votes
Accepted

How to replace a word with spaces

Move cursor anywhere on the word "test" and then viwr (the last one is a space). Saves at least two key strokes. v start visual selection iw text object "inner word" (see :help text-object, read ...
Ralf's user avatar
  • 9,317
12 votes

Jumping to a byte offset, and displaying position as byte offset

You can hit g Ctrl+g and you get the full information about the position: Col 13 of 35; Line 18 of 2272; Word 70 of 7767; Char 410 of 50021; Byte 410 of 50118
Vivian De Smedt's user avatar
12 votes

How to replace inner text with yanked text

You can use the numbered register. First yank "foo-bar" with yi", which will fill the "0 register, see :h "0. Then do ci"<c-r>0 to replace with the content of the register 0. See :h i_CTRL-R ...
Karl Yngve Lervåg's user avatar
12 votes
Accepted

Extend visual selection until the last character on the line (excluding the new line character)

Your first and third points are answered by g_, which moves to the last non-whitespace character on the line. So, vg_ will visual select to the end of the line, excluding any whitespace and the ...
Doorknob's user avatar
  • 15.4k
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
10 votes
Accepted

How to go to the end of the line even in on a wrapped line?

You're looking for g0 and g$ which are the equivalent of 0 and $ for wrapped lines. See :h g0, :h g$ and even :h g^. To quote the doc about g$: When lines wrap ('wrap' on): To the last character ...
statox's user avatar
  • 50.2k
10 votes
Accepted

How can a mapping have behavior dependent on the presence of a count?

You can use expression maps and Vim's predefined v:count variable to do this: nnoremap <expr> j v:count > 1 ? "j" : "gj" nnoremap <expr> k v:count > 1 ? "k" : "gk" This checks the ...
Rich's user avatar
  • 32.3k
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.2k
9 votes

How to replace inner text with yanked text

Here is another solution. It's not the best in term of Vimgolf, but it uses the black hole register: Once you're on the foo bar string you can yank it normally using yi". Then inside the brackets to ...
statox's user avatar
  • 50.2k
9 votes

How to replace inner text with yanked text

I need this so often, I wrote a plugin to simplify and allow maximum speed: ReplaceWithRegister. This plugin offers a two-in-one gr command that replaces text covered by a {motion} / text object, ...
Ingo Karkat's user avatar
  • 17.9k
9 votes
Accepted

Go to Nth character in the file?

Excluding newlines There is a command for go to next character, it is <space>. I assume the option whichwrap is default of b,s so that space wraps to the next line, and conceallevel is 0 so no ...
Mass's user avatar
  • 14.2k
9 votes
Accepted

Vim: what are the fastest ways to get to the middle of some line close to where your cursor is located?

What is the quickest way to do that? If such things as "purity" or "efficiency" are important to you, then the fastest native method is: ?,<CR> where: :help ? starts ...
romainl's user avatar
  • 41.4k
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

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

As of October 2019, we have gM, which moves the cursor to the middle of the line. This requires Vim 8.1.2231 or later.
milosz.lakomy_gmail.com's user avatar

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