How do I capitalize the first letter of every word in a file using a substitute command?
:%s/\w\+/\u&/g
Vim's substitute command supports case-conversion modifiers in the replacement string.
Search Vim Tricks
Searching...:%s/\w\+/\u&/g
Vim's substitute command supports case-conversion modifiers in the replacement string.
[/
When editing code, you often need to navigate to the boundaries of multi-line block comments (/ .
:let @a = '...'
When a recorded macro contains a typo or needs a small tweak, you can modify it directly via the :let command rather than re-recording the entire sequence.
:set nofixendofline
By default, Vim enforces POSIX compliance by appending a final newline to any file that lacks one.
:digraphs
:digraphs (abbreviated :dig) displays a full reference table of every digraph registered in Vim.
command-line #editing #special-characters #insert-mode #command-line
=ip
The =ip command combines Vim's auto-indent operator (=) with the inner paragraph text object (ip) to re-indent every line in the current paragraph in a single k
m<
Vim's ' marks record the start and end of the last visual selection and power the ' range used by Ex commands.
:vertical {cmd}
The :vertical command modifier forces any window-opening Ex command to create a vertical split instead of the default horizontal split.
buffers-windows #windows #buffers #command-line #splits #ex-commands
{Visual}<C-a>
In Visual mode, pressing increments every number within the selection by 1 (or by a given [count]).
set showbreak=↪\
When wrap is enabled, long lines visually wrap to the next screen row.
:set nojoinspaces
By default, Vim follows an old typesetting convention and inserts two spaces after a period, exclamation mark, or question mark when joining lines with J.
:e ++ff=unix
The ++ff modifier forces Vim to re-read the current file from disk using a specific fileformat — unix (LF), dos (CRLF), or mac (CR).
set foldmarker=start,end
When using foldmethod=marker, Vim uses {{{ and }}} as the default fold open and close markers.
:[range]right [width]
Vim's :right command right-aligns text by padding lines with leading spaces up to a given width.
/\c
Vim lets you override the ignorecase and smartcase settings on a per-search basis using the \c (case-insensitive) and \C (case-sensitive) atoms directly inside
yiw{nav}viwp{nav}viwp
When you paste over a visual selection in Vim, the displaced text is moved into the unnamed register "".
registers #registers #visual-mode #editing #text-objects #normal-mode
{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
ZZ
ZZ is a normal mode shorthand that saves and quits only if the buffer has been modified.
mt and mc in netrw
Netrw, Vim's built-in file browser, has a full file-management workflow driven by marks.
<C-a> in insert mode
Pressing while in insert mode inserts the same text that was typed during the previous insert mode session.