How do I change the case of text during a search and replace?
:%s/\<word\>/\u&/g
Vim's substitute command supports case conversion modifiers in the replacement string.
366 results for ":w"
:%s/\<word\>/\u&/g
Vim's substitute command supports case conversion modifiers in the replacement string.
:terminal
The :terminal command opens an interactive terminal emulator directly inside a Vim window.
:X
The :X command sets an encryption key for the current file.
command-line #command-line #security #file-management #ex-commands
yiww"_ciw\<C-r>0\<Esc>
When you are doing repetitive refactors, cw is fast but it overwrites the unnamed register with the replaced text.
:diffoff!
The :diffoff! command exits diff mode in every window simultaneously.
g~iw
The g~iw command toggles the case of every character in the word under the cursor — uppercase letters become lowercase and vice versa.
:saveas
The :saveas {filename} command writes the current buffer to a new file and makes that new file the current buffer's file.
\u / \l / \U / \L (in :s replacement)
Vim's :substitute replacement string supports case-conversion modifiers that let you uppercase or lowercase matched text without writing a separate command.
:view {file}
:view opens a file with the readonly option set, preventing accidental writes.
:s/\v(pattern1)(pattern2)/\2\1/
Vim's substitute command supports capture groups (also called backreferences), which let you rearrange matched portions of text.
:%s/\(prefix\)\@<=target/replacement/g
Vim's \@<= is a zero-width look-behind assertion.
:set foldmethod=marker
Setting foldmethod=marker lets you define fold boundaries using special comment markers — {{{ to start a fold and }}} to end it.
\@>
Vim's \@> syntax creates an atomic group in a regular expression.
qa/pattern<CR>dd@aq
By starting a macro with a search command, the macro becomes conditional — it jumps to the next match before acting, and terminates when no more matches are f
:%s/\r//g
When a file created on Windows is opened in Vim on a Unix system, lines may retain \r (carriage return) characters, displayed as ^M at the end of each line.
:set shortmess+=I
The shortmess option is a string of single-character flags that tell Vim which messages to suppress or abbreviate.
:pedit +/TODO %
When you need a second read-only view of the same file, opening more normal splits can disrupt your working layout.
: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
:TOhtml
The :TOhtml command converts the current buffer — complete with its syntax highlighting colors — into a standalone HTML file.
:set winfixbuf
Neovim's winfixbuf option (added in Neovim 0.