How do I paste text and leave the cursor after the pasted content instead of on it?
gp
The standard p command pastes text after the cursor but leaves the cursor at the beginning of the pasted text.
gp
The standard p command pastes text after the cursor but leaves the cursor at the beginning of the pasted text.
<C-a> (in insert mode)
While in insert mode, pressing re-inserts whatever text you typed during your previous insert session.
:/start/,/end/d
Instead of specifying line numbers for Ex command ranges, you can use search patterns.
command-line #ex-commands #editing #search #ranges #command-line
:'<,'>!column -t
When working with data that has uneven spacing — such as variable assignments, CSV-like data, or configuration entries — you can select the lines and pipe t
visual-mode #visual-mode #editing #formatting #external-command #alignment
[{ / ]}
When editing code inside a deeply nested block, [{ jumps backward to the unmatched { that encloses the current position, and ]} jumps forward to its matching }.
<C-y> / <C-e>
When typing in insert mode, you can pull individual characters from adjacent lines without leaving insert mode.
<C-r><C-o>{reg}
When you use a in insert mode to paste register a, Vim inserts the text as if you typed it character by character.
v / V / <C-v> (while in visual mode)
When you are already in visual mode and realize you need a different selection type, you do not have to exit and re-enter.
:put a ... edit ... "ayy
Recorded macros are stored as plain text in registers, but editing them by re-recording is tedious for complex sequences.
:diffget / :diffput
When comparing two files side by side with :diffsplit or vim -d, you often want to pull specific changes from one file into another rather than accepting all di
:undojoin
When writing Vim scripts or running multiple Ex commands, each command normally creates a separate undo entry.
<C-t> and <C-d> in insert mode
When typing in insert mode, you can adjust the current line's indentation without leaving to normal mode.
]m and [m
The ]m and [m motions let you jump forward and backward between the start of method or function definitions.
qqqqqq{edits}@qq
A recursive macro calls itself at the end of its sequence, creating a loop that automatically repeats until a motion or command fails (such as hitting the last
:.+1,.+3d
Vim's Ex command addresses support arithmetic offsets relative to the current line (.
command-line #ex-commands #editing #navigation #command-line
:g/^/m 0
This clever use of the :global command reverses every line in the current buffer.
command-line #editing #ex-commands #global #text-manipulation
autocmd FileType python setlocal ts=4 sw=4 et
Using autocmd FileType, you can configure Vim to automatically apply buffer-local settings whenever a file of a particular type is opened.
dp and do
When comparing two files side by side in Vim's diff mode (:diffsplit or vim -d file1 file2), you often want to accept or push individual changes between the fil
gq
The gq operator reformats text to fit within your configured textwidth.
:ilist /pattern/
The :ilist command searches for a pattern not only in the current buffer but also in files referenced by #include directives (or whatever 'include' is set to).