How do I browse the full commit history of the current file using vim-fugitive?
:G log -- %
vim-fugitive's :G log -- % loads the git commit history for the current file into a quickfix-style log buffer.
:G log -- %
vim-fugitive's :G log -- % loads the git commit history for the current file into a quickfix-style log buffer.
\@<= and \@=
Vim's regex engine supports zero-width lookahead and lookbehind assertions using the \@ atom.
:windo {cmd}
:windo {cmd} executes an Ex command in every window in the current tab page, cycling through each one and applying the command before returning focus to the ori
buffers-windows #windows #buffers #ex-commands #buffers-windows
<C-v>I
Visual block mode's I command lets you type once and have the text inserted at the cursor column across all selected lines simultaneously.
"1p then u. to cycle through delete history
Vim silently maintains a rolling history of your last 9 deletions in numbered registers "1 through "9.
:s/pattern/\=expr/
Prefixing the replacement field of :s with \= makes Vim evaluate the rest as a Vimscript expression and use the result as the replacement string.
Record worker macro in @b, call it from @a with @b
Complex macros are hard to debug and maintain when crammed into a single register.
<C-r><C-r>{register}
In insert mode, {register} pastes the register's contents but runs it through Vim's insert-mode processing — including autoindent, textwidth wrapping, and for
:g/pattern/normal {cmd}
Combining :global with :normal lets you run any normal-mode keystrokes on every line that matches a pattern.
g<C-]>
When a symbol (function, class, variable) is defined in multiple places, CTRL-] blindly jumps to the first match.
\@=
Vim's regex engine supports zero-width lookahead and lookbehind assertions using the \@ family of atoms.
[[
The [[ and ]] commands navigate between top-level code blocks — specifically, lines where { appears in column 1.
:e +{line} {file}
The :edit command accepts a +{cmd} prefix that executes an Ex command immediately after the file is loaded.
command-line #buffers #ex-commands #navigation #command-line
:s/\d\+/\=submatch(0)+1/g
The \= prefix in a :substitute replacement field tells Vim to evaluate the following as a Vimscript expression rather than treating it as a literal string.
:'<,'>s/\%Vpattern/replacement/g
When you press : after making a visual selection, Vim inserts ' to restrict the substitution to the selected lines.
visual-mode #visual-mode #search #editing #ex-commands #normal-mode
/\cfoo
Vim's \c and \C flags let you force a search to be case-insensitive or case-sensitive on a per-search basis, regardless of your ignorecase and smartcase setting
:echo strtrans(@q)
When a macro behaves unexpectedly, :echo strtrans(@q) reveals exactly what is stored in register q—including invisible control characters—as human-readable
:vim /pattern/ **
:vimgrep /pattern/ (shortened to :vim) is Vim's built-in project-wide search.
gq (visual mode)
Pressing gq on a visual selection reformats the selected lines to hard-wrap at textwidth columns.
:let @a = system('cmd')
You can populate any Vim register with the output of an external shell command using :let @{register} = system('{command}').