How do I search for text that simultaneously matches two different patterns using Vim's AND operator?
/pattern1\&pattern2
Vim's \& operator lets you intersect two patterns so the match must satisfy both simultaneously.
/pattern1\&pattern2
Vim's \& operator lets you intersect two patterns so the match must satisfy both simultaneously.
crs / crc / crm / cru
The vim-abolish plugin adds coercion operators that instantly convert the word under the cursor between common naming conventions.
plugins #editing #text-objects #plugins #normal-mode #formatting
zi
Pressing zi in normal mode toggles the foldenable option, which controls whether folds are active in the current window.
g8
Pressing g8 in normal mode displays the UTF-8 encoding of the character under the cursor as a sequence of hex bytes.
:call setreg('q', 'dd')
The setreg() VimScript function lets you populate any register with arbitrary content directly from the command line or a script — no recording required.
/prefix\zsword
Vim's \zs atom marks the start of the match within a longer pattern.
das
Vim defines a sentence as text ending with .
editing #editing #text-objects #delete #normal-mode #motions
:set nrformats+=hex
By adding hex to the nrformats option, you tell Vim to recognise hexadecimal literals such as 0xFF or 0xDEAD when or is pressed.
\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.
:[range]join
The :[range]join Ex command lets you join lines by specifying an explicit line range — without having to navigate there or use visual selection.
:sort r /pattern/
The :sort r /pattern/ command sorts lines using the matched portion of the regex as the sort key.
:for i in range(1,5) | put ='item '.i | endfor
Vimscript's for loop is available directly from Vim's command line and can be used to generate repetitive or parameterized text without a macro or external scri
:%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.
nnoremap <expr> j (v:count == 0 ? 'gj' : 'j')
The map modifier turns a mapping's right-hand side into a Vimscript expression that is evaluated at the time the key is pressed, with its return value used as t
:let @a = @"
Vim's :let command lets you read and write register contents as strings, making it possible to copy, combine, or modify register values without ever leaving the
<C-v>{motion}I{text}<Esc>
Visual block mode () lets you select a rectangular region across multiple lines.
/pattern1\_.{-}pattern2
Vim's regex engine normally treats .
mA
Uppercase marks (A–Z) are global marks in Vim — they persist across files and even across sessions (when viminfo or shada is configured).
[i
Pressing [i in normal mode displays the first line above the cursor (including included files) that contains the keyword under the cursor.
:s/\v\w+/\U&/g
Vim's substitute command supports special case-conversion sequences in the replacement string, letting you transform matched text to upper or lower case without