How do I insert today's date into a Vim buffer using the expression register?
<C-r>=strftime('%Y-%m-%d')<CR>
The expression register ("=) lets you evaluate any Vimscript expression and insert its result inline.
category:
registers
tags:
#registers
#insert-mode
#expression-register
#dates
How do I customize Vim's statusline to show useful file information?
:set statusline=%f\ %y\ [%l/%L]
Vim's statusline option lets you build a custom status bar from format items.
category:
config
tags:
#config
#formatting
How do I indent or unindent the current line while staying in Insert mode?
While in Insert mode, you can adjust indentation without switching back to Normal mode.
category:
editing
tags:
#editing
#insert-mode
#indentation
How do I create text shortcuts that auto-expand while typing in Vim?
:iabbrev defines insert-mode abbreviations that expand automatically when you type a non-keyword character (space, punctuation, ) after the abbreviation.
category:
config
tags:
#insert-mode
#config
#editing
How do I add more keystrokes to the end of an existing macro without re-recording the whole thing?
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.
category:
macros
tags:
#macros
#registers
#normal-mode
How do I speed up Vim's insert mode completion by disabling include-file scanning?
Vim's complete option controls which sources are scanned when you press or to complete a word.
category:
config
tags:
#completion
#config
#performance
#insert-mode
How do I run a normal mode command on every visually selected line?
After making a visual selection, :'normal {command} runs any normal-mode command on each selected line individually.
category:
visual-mode
tags:
#visual-mode
#ex-commands
#normal-mode
#editing
How do I check if a specific Vim feature or capability is available before using it in my vimrc?
The has('feature') function returns 1 if the specified feature is available in the current Vim/Neovim instance, 0 otherwise.
category:
config
tags:
#config
#vimscript
#portability
How do I search across all of Vim's help documentation for a keyword or phrase?
:helpgrep searches the full text of every Vim help file for a pattern and loads all matches into the quickfix list.
category:
search
tags:
#search
#ex-commands
#navigation
How do I search across files and populate the quickfix list without jumping to the first match?
By default, :vimgrep jumps your cursor to the first match it finds, which can be disorienting when you just want to collect results and browse them on your own
category:
search
tags:
#search
#ex-commands
#buffers
How do I open the previous file I was editing in a split window?
In Vim, # is a special filename that always refers to the alternate file — the most recently active buffer before the current one.
category:
buffers-windows
tags:
#buffers
#windows
#navigation
#editing
How do I open or edit a file in the same directory as the file I am currently editing?
Vim expands % to the current file's path in Ex commands, and the :h modifier strips the last filename component to give you just the directory.
category:
command-line
tags:
#ex-commands
#buffers
#navigation
#editing
How do I recover the last small deletion without disrupting my numbered registers?
Vim silently stores every deletion of less than one line in the special "- register (the "small delete" register).
category:
registers
tags:
#registers
#editing
#normal-mode
How do I move the cursor to the top of the visible screen?
The H command moves the cursor to the first line of the currently visible screen (the "High" position).
category:
navigation
tags:
#navigation
#motions
#normal-mode
How do I open the file whose name is under the cursor in a new tab?
gf reads the filename under the cursor and opens it in a new tab page, keeping your current buffer untouched.
category:
navigation
tags:
#navigation
#buffers-windows
#tabs
How do I evaluate a Vimscript expression and insert the result into a command-line command?
<C-r>= (command-line mode)
Just like = lets you insert evaluated expressions in insert mode, you can use it inside an Ex command on the command line to embed any Vimscript expression resu
category:
command-line
tags:
#registers
#ex-commands
#command-line
How do I write a non-greedy (lazy) quantifier in Vim's search regex?
In Vim's regex engine, \{-} is the non-greedy (lazy) quantifier — it matches as few characters as possible, unlike .
category:
search
tags:
#search
#regex
#patterns
#substitution
How do I load shell search output into a window-local location list?
:lgetexpr systemlist('rg --vimgrep TODO %') | lopen
When you want search results tied to only the current window, use :lgetexpr instead of :cgetexpr.
category:
buffers-windows
tags:
#location-list
#quickfix
#buffers
#command-line
#search
How do I see the raw UTF-8 byte values of the character under the cursor?
Pressing g8 in normal mode displays the UTF-8 encoding of the character under the cursor as a sequence of hex bytes.
category:
navigation
tags:
#navigation
#encoding
#unicode
#normal-mode
How do I match a pattern only when it is preceded or followed by another pattern, without including that context in the match?
Vim's regex engine supports zero-width lookahead and lookbehind assertions using the \@ family of atoms.
category:
search
tags:
#search
#editing
#normal-mode