How do I match an optional sequence of characters at the end of a word in a Vim regex?
\%[abc]
The \%[.
Search Vim Tricks
Searching...\%[abc]
The \%[.
:set foldcolumn=3
The foldcolumn option adds a narrow column on the left side of the window that visually represents the fold structure of the file.
zr and zm
The zr and zm commands let you incrementally adjust the global fold depth across the entire buffer — one level at a time.
<C-a> (command-line mode)
In command-line mode, inserts all completions for the word before the cursor at once, as a space-separated list.
:compiler {name}
The :compiler command loads a compiler plugin from Vim's runtime path, setting both makeprg (the build command) and errorformat (the error parsing pattern) in o
:set makeprg={command}
Vim's :make command runs a build program and automatically loads its output into the quickfix list so you can jump directly to errors and warnings.
:{range}center [width]
Vim provides three built-in Ex commands for text alignment: :center, :right, and :left.
:lcd %:p:h
:lcd %:p:h sets the working directory for the current window to the directory of the file you're editing, using Vim's path expansion modifiers.
:echo map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")')
When syntax highlighting looks wrong or a colorscheme override isn't taking effect, you need to know exactly which highlight groups are active under the cursor.
@+
In Vim, @{register} executes the contents of any register as a macro.
: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/pattern//n
The n flag in the substitute command suppresses the actual replacement and instead reports the match count.
:%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.
:set jumpoptions=stack
By default Vim's jump list is a ring: if you press to go back several positions and then make a new jump, the list wraps around and future entries are preserved
:set fillchars+=eob:
By default, Vim fills empty lines after the end of a buffer with ~ characters.
:set wildoptions=pum
Setting wildoptions=pum tells Neovim to use its popup menu for command-line tab completion instead of the traditional horizontal wildmenu bar.
:set diffopt+=linematch:60
Neovim's linematch diffopt enables intra-line diff highlighting — instead of marking an entire changed line, Neovim highlights only the specific characters th
qQ (or any uppercase register letter)
When recording a macro with qq, you can append additional keystrokes to the existing macro by recording into the uppercase version of the same register.
nnoremap <key> <Cmd>command<CR>
The special key (Vim 8.
config #config #macros #ex-commands #normal-mode #insert-mode
:TOhtml
The :TOhtml command converts the current buffer — complete with its syntax highlighting colors — into a standalone HTML file.