How do I resize the current window to an exact number of lines from the command line?
The z{height} command simultaneously resizes the current window to exactly {height} lines, scrolls so the current line sits at the top of the window, and moves
category:
buffers-windows
tags:
#buffers-windows
#windows
#resize
#navigation
How do I extend my incremental search pattern one character at a time from the current match without retyping?
When searching with incsearch enabled, Vim highlights matches as you type.
category:
search
tags:
#search
#incsearch
#normal-mode
How do I insert the contents of another file into the current buffer?
The :r filename command reads the contents of filename and inserts them into the current buffer below the cursor line.
category:
command-line
tags:
#ex-commands
#editing
#buffers
How do I create a self-repeating macro that runs until there is nothing left to process?
@q (inside macro recording)
A recursive macro calls itself as its last action, causing it to repeat indefinitely until it hits an error (like reaching end of file or failing a search).
category:
macros
tags:
#macros
#registers
#normal-mode
#editing
How do I wrap a word or text object with quotes, brackets, or tags in Vim?
The vim-surround plugin provides the ys (you surround) operator to wrap any Vim text object or motion with a delimiter pair.
category:
plugins
tags:
#plugins
#surround
#editing
#text-objects
#normal-mode
How do I copy text to the system clipboard in Vim?
The "+y command yanks (copies) text into the system clipboard register, making it available to paste in other applications outside of Vim.
category:
registers
tags:
#registers
#yank
#editing
#normal-mode
How do I paste the current filename into the buffer?
The % register in Vim always contains the name of the current file.
category:
registers
tags:
#registers
#editing
#insert-mode
#productivity
#filename
How do I suppress the 'Pattern not found' error when a substitution has no match?
The e flag in Vim's :substitute command silently ignores the "E486: Pattern not found" error when the pattern does not match anything.
category:
search
tags:
#search
#substitute
#ex-commands
#macros
#editing
How do I use a counter variable inside a Vim macro?
:let i=1 then use <C-r>=i<CR> in macro
By combining a Vimscript variable with the expression register inside a macro, you can create a counter that increments on each replay.
category:
macros
tags:
#macros
#vimscript
#counter
#expression
#advanced
How do I resolve a 3-way merge conflict by pulling changes from a specific buffer in diff mode?
When Vim's diff mode has three or more buffers open, :diffget (or do) without an argument is ambiguous — Vim cannot determine which buffer to pull from.
category:
buffers-windows
tags:
#buffers
#windows
#ex-commands
How do I insert the output of a shell command into my file?
The :r !command command executes a shell command and inserts its output directly into the current buffer below the cursor line.
category:
command-line
tags:
#command-line
#ex-commands
#editing
How do I make a macro run repeatedly until it reaches the end of the file or encounters an error?
A recursive macro is a macro that calls itself at the end of its recording.
category:
macros
tags:
#macros
#editing
#normal-mode
#registers
How do I manage files and directories as a regular Vim buffer?
oil.nvim: edit directory listing like a buffer
oil.
category:
plugins
tags:
#plugins
#file-management
#neovim
#oil
#workflow
How do I define a custom user command in Neovim Lua config that accepts arguments and has a description?
vim.api.nvim_create_user_command()
Neovim's Lua API provides vim.
category:
config
tags:
#config
#neovim
#lua
#command-line
#ex-commands
How do I open a file path that appears in my code without manually typing it?
The gf command ("go to file") opens the file whose path is under the cursor.
category:
navigation
tags:
#navigation
#normal-mode
#buffers
#productivity
#file-management
How do I create a macro that repeats itself until it hits an error or end of file?
A recursive macro is one that calls itself at the end of its own body.
category:
macros
tags:
#macros
#registers
#normal-mode
How do I select a rectangular block of text in Vim?
The (Ctrl+v) command enters visual block mode, which lets you select a rectangular column of text across multiple lines.
category:
visual-mode
tags:
#visual-mode
#editing
#normal-mode
How do I open a terminal inside Vim?
The :terminal command opens an interactive terminal emulator directly inside a Vim window.
category:
command-line
tags:
#command-line
#ex-commands
#buffers-windows
How do I run an interactive git blame inside Vim?
The vim-fugitive plugin by Tim Pope provides a powerful interactive :Git blame that goes far beyond the basic command-line git blame.
category:
plugins
tags:
#plugins
#fugitive
#git
#blame
#history
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