How do I create a Vim mapping where the keys it produces are computed dynamically at runtime?
:nnoremap <expr> {key} {expression}
The argument to any map command (:nmap, :inoremap, etc.
config #config #macros #insert-mode #normal-mode #ex-commands
:nnoremap <expr> {key} {expression}
The argument to any map command (:nmap, :inoremap, etc.
config #config #macros #insert-mode #normal-mode #ex-commands
:set {option}&
Append & to any :set command to reset that option to its compiled-in default value — the value Vim shipped with before any vimrc or plugin changed it.
:set wildmode=list:longest
Vim's wildmode option controls how the command line behaves when you press to complete filenames, buffer names, or Ex commands.
zG
zG marks the word under the cursor as correctly spelled in Vim's internal word list, which exists only for the current session.
:set exrc secure
Adding set exrc to your vimrc tells Vim to read a .
:set foldmethod=expr
Setting foldmethod=expr tells Vim to call the foldexpr expression for every line to compute its fold level.
:set foldtext={expr}
The foldtext option controls what Vim displays for a closed fold.
vim.opt.option:append(value)
Neovim's vim.
:set wildcharm=<Tab>
The wildcharm option designates a key that, when it appears inside a mapping, triggers wildmenu completion on the command line — just as if you had pressed in
:iabbrev {lhs} {rhs}
The :iabbrev command defines insert-mode abbreviations — short character sequences that automatically expand into longer text when you type a non-keyword char
:let $VAR = "value"
Vim lets you read and write environment variables using the $VARIABLE syntax in Vimscript.
:set path+=** | :find
By adding to Vim's path option and using :find, you can search for any file recursively through your project tree with tab completion — no plugins required.
:set foldopen
The foldopen option lets you specify exactly which cursor movements and commands will automatically open a closed fold.
fnameescape(filename)
When building Vim Ex commands dynamically, filenames with spaces, , %, #, [, or other special characters will be misinterpreted — the space looks like an argu
globpath(&rtp, 'pattern')
globpath() is a Vimscript function that searches all directories in a given path list for files matching a glob pattern.
:echohl WarningMsg | echo "message" | echohl None
:echohl sets the highlight group applied to subsequent :echo and :echom output.
:set display=lastline
By default, when the last visible line of a window is too long to fit on screen, Vim shows @@@ in its place — hiding the content entirely.
autocmd ++once
The ++once flag, added in Vim 8.
:set formatprg={program}
Vim's gq operator normally reflows text to fit textwidth, but by setting formatprg you can delegate formatting to any external tool — a language formatter, a
:trust
Neovim supports project-local configuration via a .