How do I get the current Vim mode as a string for use in expression mappings or the statusline?
The mode() function returns a short string identifying the current editing mode — 'n' for Normal, 'i' for Insert, 'v' for Visual character-wise, 'V' for Visua
category:
macros
tags:
#macros
#normal-mode
#visual-mode
#insert-mode
#editing
How do I prompt the user for input in the middle of a mapping or Vimscript function?
The built-in input() function pauses execution, displays a prompt at the bottom of the screen, and returns whatever the user types before pressing Enter.
category:
macros
tags:
#macros
#editing
#ex-commands
#insert-mode
How do I make Tab and Enter behave differently when the completion popup menu is open?
The pumvisible() function returns 1 when the insert-mode completion popup menu (pum) is visible, and 0 otherwise.
category:
config
tags:
#config
#insert-mode
#completion
How do I create a dynamic abbreviation that inserts live content like the current date?
:iabbrev <expr> {trigger} {expression}
The flag on :iabbrev turns the right-hand side into a Vimscript expression that is evaluated at expansion time rather than stored as a literal string.
category:
config
tags:
#config
#insert-mode
#abbreviations
#ex-commands
How do I change the cursor shape to a thin bar in insert mode and a block in normal mode in Neovim?
:set guicursor=n-v-c:block,i-ci-ve:ver25,r-cr:hor20
Neovim's guicursor option lets you assign a distinct cursor shape and style to each mode, providing immediate visual feedback about which mode you are in.
category:
config
tags:
#config
#normal-mode
#insert-mode
#visual-mode
How do I instantly erase everything I have typed on the command line and start the command over?
When you are typing a long Ex command on the : prompt and realise you've made a mistake, pressing erases everything from the cursor back to the beginning of the
category:
command-line
tags:
#command-line
#ex-commands
#editing
#insert-mode
How do I use the caret mark to jump to the exact cursor position where I last left insert mode?
Vim automatically maintains a special mark ^ that records the exact position of the cursor the last time you left insert mode.
category:
navigation
tags:
#navigation
#marks
#insert-mode
#normal-mode
How do I show documentation for the selected completion item in a popup window?
Adding popup to completeopt makes Vim display extra information — such as function signatures or documentation — for the currently highlighted completion it
category:
config
tags:
#completion
#insert-mode
#config
#editing
How do I type special characters and symbols using Vim's built-in digraph system in insert mode?
Vim's digraph system lets you insert special characters, accented letters, and symbols by typing a memorable two-character sequence.
category:
editing
tags:
#insert-mode
#special-characters
#unicode
#editing
How do I include spell-checked words as completion candidates in Vim insert mode?
Adding kspell to the complete option makes and draw from the active spell word list — every word Vim considers correctly spelled.
category:
config
tags:
#completion
#insert-mode
#spell
#config
#editing
How do I move the cursor in insert mode without creating an undo break point?
By default, moving the cursor with arrow keys while in insert mode creates an undo break — meaning a subsequent u will undo only back to when you last moved,
category:
editing
tags:
#insert-mode
#undo-redo
#editing
#advanced
How do I make keyword completion preserve the capitalization style I started typing?
The infercase option makes Vim's keyword completion smart about capitalization: it adapts each match to reflect the casing of the characters you've already type
category:
config
tags:
#completion
#insert-mode
#config
How do I define the comment format Vim uses for auto-commenting and plugins like vim-commentary?
:set commentstring=//\ %s
The commentstring option controls the template Vim uses to represent commented-out lines.
category:
config
tags:
#config
#comments
#formatting
#insert-mode
#autocmd
How do I autocomplete macro-defined identifiers from header files while in insert mode?
in insert mode triggers defined identifier completion — it searches for identifiers that match the partial word before the cursor by scanning #define statemen
category:
editing
tags:
#editing
#insert-mode
#completion
How do I programmatically exit insert mode from an autocommand or Vimscript function?
:stopinsert is an Ex command that immediately exits insert (or replace) mode and returns to normal mode.
category:
command-line
tags:
#insert-mode
#ex-commands
#autocommands
#normal-mode
How do I trigger an autocommand action after the cursor has been idle for a set period?
The CursorHold autocommand event fires once whenever the cursor has been motionless in normal mode for updatetime milliseconds.
category:
config
tags:
#config
#autocommands
#events
#insert-mode
How do I insert a literal control character or special key into the command line?
<C-v> (command-line mode)
In command-line mode (after : or /), pressing followed by any key inserts that key literally — bypassing all key notation, mappings, and special interpretatio
category:
command-line
tags:
#command-line
#search
#editing
#insert-mode
How do I quickly append text to the end of a word under the cursor in Vim?
The ea compound shortcut moves to the last character of the current word with e, then enters insert mode after the cursor with a.
category:
editing
tags:
#editing
#motions
#insert-mode
#normal-mode
How do I paste a register literally in insert mode without triggering auto-indent or special key handling?
When you press x in insert mode to paste a register, Vim inserts the text "as if you typed it" — meaning autoindent, textwidth, and other insert behaviors can
category:
registers
tags:
#registers
#insert-mode
#editing
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.
category:
config
tags:
#config
#macros
#insert-mode
#normal-mode
#ex-commands