Text objects
The commands that start with “a” select “a”n object including white space, the commands starting with “i” select an “inner” object without white space, or just the white space. Thus the “inner” commands always select less text than the “a” commands.
as
: “a sentence”is
: “inner sentence”ap
: “a paragraph”ip
: “inner paragraph”
Also w
and W
for words, t
for HTML tags, and any pair of symbols: (<{"'[
.
Macro tricks
Use va{V
to select the outer block line-wise.
Scrolling
z., zt, zb move "cursor line" into respective position
H, L, M move cursor to respective position
Marks
m
followed by a letter sets a mark. a lowercase letter is local to the current buffer, but an uppercase letter can jump between files.
'
or ` followed by a letter jumps to the respective mark.
Removing auto-inserted comment leader
After pressing Enter or ‘o’, use CTRL-U
to remove the comment leader. See :help fo-table
.
o Automatically insert the current comment leader after hitting 'o' or
'O' in Normal mode. In case comment is unwanted in a specific place
use CTRL-U to quickly delete it. i_CTRL-U
Visual-block edits
Tips: use gv
to re-select the previous area in the same mode.
With a blockwise selection, A{string}
appends the string
to end of block on every line of the block, I{string}
inserts the string
at the start of block on every line of the block.
To paste lines of text to the end of a blockwise selection, first make a blockwise selection of the text to copy and yank it, then insert a placeholder character after the end of block on each line, select the placeholder row and press p
or P
. Both would delete the placeholder column (end of block) and insert text there.