How do I rename a variable across all its case variants (camelCase, snake_case, SCREAMING_CASE) in one command?
:Subvert/{src}/{tgt}/g
vim-abolish provides :Subvert, a smarter substitute that detects and preserves the case style of each match.
Search Vim Tricks
Searching...:Subvert/{src}/{tgt}/g
vim-abolish provides :Subvert, a smarter substitute that detects and preserves the case style of each match.
:tab {cmd}
Most commands that open a new window (:help, :split, :new, :terminal) open a horizontal split by default.
:let @+=@%
The % register always holds the name of the current file (as a relative path).
<C-v>{motion}$A
In visual block mode, pressing $ makes the right edge of the selection "ragged" — it extends to the real end of each line regardless of length.
/\%V
The \%V pattern atom restricts a search to the region spanned by the last visual selection.
\%(pattern\)
In Vim's regex engine, \( and \) create a capturing group whose contents are stored in \1, \2, etc.
:keepjumps {cmd}
:keepjumps is a command modifier that suppresses any jump list updates caused by the command that follows it.
:bufdo {cmd}
:bufdo executes an Ex command in each open buffer in sequence, cycling through every buffer in the buffer list.
:cdo {cmd}
:cdo executes an Ex command on every entry in the quickfix list in sequence, visiting each match in turn.
qa{actions}@aq
A recursive macro is one that calls itself as its final action, causing it to repeat indefinitely until any command in the body fails (e.
<C-y> (above) / <C-e> (below)
In insert mode, inserts the character from the same column one line above, and inserts the character from the same column one line below.
cx{motion} … cx{motion} (vim-exchange)
The vim-exchange plugin provides cx{motion} to mark a region, then cx{motion} again on a second region to swap them in place.
:sball
The :sball command (short for split all) opens every loaded buffer in its own horizontal split window in one shot.
:cnoremap %% <C-r>=expand('%:h').'/'<CR>
By mapping %% in command-line mode, you can type %% wherever you would normally type a path and have Vim automatically expand it to the directory of the current
\%V (in search/substitute pattern)
The \%V atom in a Vim pattern matches only inside the last visual selection.
search #search #visual-mode #substitution #regex #normal-mode
!{motion}{cmd}
The ! operator in normal mode lets you pipe any motion's text through a shell command and replace it with the output.
editing #editing #shell #external-command #normal-mode #filtering
<C-r><C-l>
Pressing on the command line inserts the full text of the current buffer line (the line the cursor is on when you pressed :) directly at the command-line cursor
:set switchbuf=useopen
The switchbuf option controls how Vim decides where to display a buffer when switching to it via commands like :sb, :cc, :cn, quickfix jumps, or .
buffers-windows #buffers-windows #navigation #ex-commands #config
:normal!
The :normal! command (with !) executes normal mode keystrokes exactly as Vim defines them, ignoring any user-defined mappings.
O (visual-block)
In Visual-Block mode (), pressing O moves the cursor to the diagonally opposite corner of the rectangular selection.