How do I make the tilde key work as a case-toggle operator so I can use motions like ~w or ~ip?
:set tildeop
By default, ~ toggles the case of a single character and advances the cursor.
:set tildeop
By default, ~ toggles the case of a single character and advances the cursor.
:{range}center [width]
Vim provides three built-in Ex commands for text alignment: :center, :right, and :left.
:s/\(\w\+\)/\u\1/g
Vim's substitute command supports case-change modifiers in the replacement string that let you capitalize, uppercase, or lowercase matched text as part of the s
:%s/\zsparseData\ze(/processData/g
Vim's \zs and \ze atoms let you include context in your search pattern without including that context in the replacement.
:TOhtml
The :TOhtml command converts the current buffer — complete with its syntax highlighting colors — into a standalone HTML file.
:g/pattern/join
The :g/pattern/join command combines the :global command with :join to merge every line matching a pattern with the line immediately following it.
command-line #ex-commands #editing #command-line #search #normal-mode
/\%d{decimal}
Vim's regex engine supports special atoms that match characters by their numeric value rather than their glyph.
:update
The :update command (abbreviated :up) writes the buffer to disk only if it has been modified since the last save.
:g/pattern1/s/pattern2/replacement/g
Combining :g with :s lets you apply a substitution using two independent patterns: :g selects which lines to act on, and :s controls what gets replaced within t
:right
Vim has three built-in Ex commands for text alignment that most users never discover: :right [width] right-justifies lines, :left [width] left-justifies (strips
<C-r>=input('Enter: ')<CR>
By embedding =input('prompt: ') inside a recorded macro, you can pause the macro at any point to ask for user input and insert the result.
[<Space> and ]<Space>
vim-unimpaired (by Tim Pope) provides paired bracket mappings for dozens of common operations.
:let i=0 | g/pattern/s/pattern/\=printf('%d', i+=1)/
By combining :let, the :g global command, and an expression substitution with \=, you can replace every match of a pattern with a unique incrementing number.
:g/./,/^$/join
Hard-wrapped text (where each sentence is on its own line) is common in commit messages, email threads, and older documentation.
:diffsplit {file}
:diffsplit {file} opens a file in a horizontal split and immediately activates diff mode, highlighting the differences between both buffers.
cr{s/m/c/k/u}
The vim-abolish plugin provides cr{type} coercions that instantly convert the word under the cursor to a different naming convention.
gw{motion}
The gw operator reformats text just like gq, but leaves the cursor exactly where it started.
:set shiftround
shiftround causes indent commands (>, always adds exactly shiftwidth spaces to whatever indentation the line already has With shiftround: > rounds up to the nex
:diffupdate
After making edits in a vimdiff session, the diff highlighting can become out of sync with the actual content — showing incorrect change markers or missing hu
:view {file}
:view opens a file with the readonly option set, preventing accidental writes.