How do I create a mapping that runs an Ex command without switching modes or affecting the current state?
nnoremap <key> <Cmd>command<CR>
The special key (Vim 8.
config #config #macros #ex-commands #normal-mode #insert-mode
nnoremap <key> <Cmd>command<CR>
The special key (Vim 8.
config #config #macros #ex-commands #normal-mode #insert-mode
:set wildignore
:set wildignore defines a comma-separated list of glob patterns that Vim excludes from wildcard expansion and file completion.
map() and filter() with lambdas
Vim 8 introduced lambda expressions with the syntax {args -> expr}, enabling concise inline list transformations.
winsaveview() and winrestview()
When writing Vimscript functions or complex mappings that move the cursor, it is essential to restore the original view afterward so the user does not notice an
:set path^=./src
Vim's :set command supports three operators for modifying list-style options: += appends, -= removes, and ^= prepends.
:Inspect
When customizing a colorscheme or debugging unexpected syntax colors, it's difficult to know which highlight group to override.
: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
:set nowrapscan
By default Vim's wrapscan option is enabled, which causes / and ? searches to wrap silently from the end of the file back to the beginning (and vice versa).
:autocmd FileType python setlocal keywordprg=pydoc3
The K command looks up the word under the cursor using the program defined by keywordprg (default: man).
:set wildcharm=<C-z>
The wildchar option (default ) triggers wildcard completion interactively on the command line.
:set synmaxcol=200
The synmaxcol option tells Vim the maximum column up to which it will apply syntax highlighting on each line.
:set winbar=%f
Neovim 0.
zg
When Vim's spell checker flags a technical term, proper noun, or project-specific identifier as misspelled, you can permanently silence it with zg ("mark as goo
:set softtabstop=4
When expandtab is enabled, Vim inserts spaces instead of a real tab character, but without softtabstop, Backspace only deletes one space at a time — not a ful
:call matchadd('ErrorMsg', 'TODO')
matchadd() lets you highlight arbitrary patterns using any highlight group — without touching the search register or search highlighting.
:set spelloptions=camel
By default, Vim treats camelCase as a single word and flags it as a spelling error even when both camel and case are correctly spelled.
augroup MyGroup | autocmd! | augroup END
Every time you run :source $MYVIMRC or :source % to reload your config, any bare autocmd calls are appended to Vim's autocommand table — no checking for dupli
:set formatoptions+=j
Adding the j flag to formatoptions causes Vim to strip the comment leader from the second line when two comment lines are joined with J.
zi
Pressing zi in normal mode toggles the foldenable option, which controls whether folds are active in the current window.
:set completeopt=menuone,noselect
By default, Vim's and completion can auto-insert the first match, or only show a menu when there are multiple matches.