How do I create text shortcuts that auto-expand while typing in Vim?
iabbrev
:iabbrev defines insert-mode abbreviations that expand automatically when you type a non-keyword character (space, punctuation, ) after the abbreviation.
370 results for "insert mode"
iabbrev
:iabbrev defines insert-mode abbreviations that expand automatically when you type a non-keyword character (space, punctuation, ) after the abbreviation.
C
The C command deletes everything from the cursor position to the end of the line and places you in insert mode.
<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
A
The A command moves the cursor to the end of the current line and enters insert mode.
<C-v>I
Visual block mode's I command lets you type once and have the text inserted at the cursor column across all selected lines simultaneously.
r{char}
The r{char} command replaces the character under the cursor with {char} without ever entering insert mode.
<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.
:set pastetoggle=<F2>
The pastetoggle option assigns a single key to toggle Vim's paste mode on and off without typing :set paste or :set nopaste every time.
%:S
When you build shell commands from Vim, file paths with spaces or special characters can break the command unless properly escaped.
command-line #command-line #filename-modifiers #shell #expansion
<C-r><C-l>
Pressing on the command line inserts the full text of the current buffer line (the line the cursor is on when you pressed :) directly at the command-line cursor
ciw
The ciw command deletes the inner word under the cursor and drops you into insert mode so you can type a replacement.
<C-v>{motion}I{text}<Esc>
Visual block mode () lets you select a rectangular region across multiple lines.
:%s/,/,\r/g
In Vim substitutions, \n and \r behave differently depending on whether they appear in the search pattern or the replacement string — a common gotcha that sur
ci{
The ci{ command deletes everything inside the nearest pair of curly braces {} and places you in insert mode to type a replacement.
:s/,/,\r/g
In Vim's :substitute command, \r in the replacement string inserts a literal newline — it splits the line at that point.
<C-n> / <C-p>
Vim has a powerful built-in completion system that requires zero plugins.
nnoremap <key> <Cmd>command<CR>
The special key (Vim 8.
config #config #macros #ex-commands #normal-mode #insert-mode
<C-r>/
Vim stores your last search pattern in the / register.
:cnoremap %% <C-r>=expand('%:h').'/'<CR>
By mapping %% in command-line mode, you can type %% wherever you would normally type a path and have Vim automatically expand it to the directory of the current
o
The o command opens a new line below the current line and places you in insert mode, ready to type.