How do I paste my last Ex command into the command line or a buffer?
<C-r>:
Vim stores your last executed Ex command in the read-only : register.
640 results for "/pattern"
<C-r>:
Vim stores your last executed Ex command in the read-only : register.
{count}gt
Prefixing gt (go to next tab) with a count jumps directly to the tab page at that position.
buffers-windows #tabs #buffers-windows #navigation #normal-mode
:keepjumps
When writing scripts or running commands that move the cursor (like :g, :s, or :normal), Vim normally adds each cursor position to the jump list.
:set grepprg=rg\ --vimgrep\ --smart-case\ --hidden\ --glob\ !.git
Vim's :grep becomes much more useful when grepprg is tuned for ripgrep and quickfix-compatible output.
:let @q = substitute(@q, 'foo', 'bar', 'g')
Recorded macros are plain text stored in registers, which means you can refactor them instead of re-recording from scratch.
:ldo s/foo/bar/ge | update\<CR>
:ldo is one of the most effective ways to perform targeted, multi-file edits without touching unrelated text.
va"
Vim's text objects let you select structured regions of text with two-keystroke shortcuts.
:cdo s/old/new/ | update
:cdo {cmd} executes a command at every entry in the quickfix list, visiting each location in turn.
:let @a .= "text"
Vim registers are just strings, and you can read and write them directly using the :let command.
:lvimgrep /\<TODO\>/gj **/* | lopen
If you want project-wide search results without polluting the global quickfix list, use a location list.
:%s/\(\w\+\)/\u\L\1/g
Vim's substitute command supports case-conversion escape sequences in the replacement string.
\{-}
In Vim's regex engine, \{-} is the non-greedy (lazy) quantifier — it matches as few characters as possible, unlike .
:<C-r>a
How it works While typing an Ex command on the command line (after pressing :), you can insert the contents of any register by pressing Ctrl-R followed by the r
I{text}<Esc>
When you need to add the same prefix to many adjacent lines, Visual Block insert is faster and safer than repeating macros or substitutions.
:e scp://user@host//path/to/file
Vim's built-in netrw plugin supports editing files over the network using protocols like SCP, SFTP, and HTTP.
:'<,'>normal! .
When you already made one correct edit, replaying it is usually safer than retyping it by hand.
[<C-d>
Vim's [ command jumps to the first definition of the macro or identifier under the cursor, searching from the beginning of the current file and through any file
m'
Vim's jump list automatically records your position whenever you make large motions (like G, /pattern, or ).
[b and ]b
The vim-unimpaired plugin by Tim Pope adds symmetric [ and ] bracket mappings for navigating common Vim lists.
plugins #navigation #buffers #quickfix #plugins #normal-mode
:profile start /tmp/profile.log | profile func *
When Vim feels sluggish during editing (not just at startup), the :profile command lets you measure the execution time of every function call.