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.
2125 results for "i" a""
iabbrev
:iabbrev defines insert-mode abbreviations that expand automatically when you type a non-keyword character (space, punctuation, ) after the abbreviation.
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.
gm
The gm command moves the cursor horizontally to the middle of the current screen width on the current line.
<C-w>R
Vim provides commands to rotate windows within a row or column, and to swap the current window with another.
:lcd
:cd changes the global working directory, affecting every window and tab in the session.
"-
Vim silently stores every deletion of less than one line in the special "- register (the "small delete" register).
:wincmd {cmd}
:wincmd {key} is the Ex command equivalent of every {key} window shortcut.
buffers-windows #buffers-windows #windows #ex-commands #normal-mode
:hide edit {file}<CR>
Normally, trying to :edit another file from a modified buffer triggers a warning and blocks the switch unless you save or force the command.
buffers-windows #buffers #windows #workflow #command-line #editing
:history /
Power users tend to run long, composable searches during refactors, but the default / and ? history navigation can be noisy when command history and search hist
:r filename
The :r filename command reads the contents of filename and inserts them into the current buffer below the cursor line.
@:
The @: command re-executes the most recently run Ex command (any command starting with :).
command-line #command-line #ex-commands #repeat #normal-mode #productivity
:Rename {newname}
vim-eunuch (by Tim Pope) adds Unix shell operations as first-class Vim commands.
"-p
The small delete register ("-) captures text from delete operations that are less than one line — like dw, x, dt.
[p
When you copy code from one indentation level and paste it at another, p preserves the original indentation, leaving your code misaligned.
:checktime
The :checktime command tells Vim to check whether any open buffers have been modified outside of Vim and prompt you to reload them.
<C-r>=system('cmd')
In command-line mode, =system('command') evaluates the shell command and inserts its output into the command line.
:UndotreeToggle
The undotree plugin provides a visual tree representation of Vim's undo history.
:cd -
The :cd - command switches Vim's global working directory back to the previous one, just like cd - in the shell.
:GBrowse
The vim-fugitive plugin combined with vim-rhubarb (for GitHub support) provides the :GBrowse command, which opens the current file on your repository's web host
:set foldmethod=marker
Setting foldmethod=marker lets you define fold boundaries using special comment markers — {{{ to start a fold and }}} to end it.