How do I move all lines matching a pattern to the top of the file?
When working with large files, you sometimes need to reorganize content by pulling all lines matching a certain pattern to the top.
category:
command-line
tags:
#global
#move
#ex-commands
#editing
#command-line
How do I enable inline character-level diff highlighting in Neovim's diff mode?
:set diffopt+=linematch:60
Neovim's linematch diffopt enables intra-line diff highlighting — instead of marking an entire changed line, Neovim highlights only the specific characters th
category:
config
tags:
#config
#diff
#buffers-windows
How do I use Neovim's built-in lazy iterator API to chain filter and map operations over a list?
vim.
category:
config
tags:
#ex-commands
How do I switch to the previous buffer in Vim?
The :bprev (or :bp for short) command switches to the previous buffer in Vim's buffer list.
category:
buffers-windows
tags:
#buffers
#ex-commands
#navigation
What built-in LSP keymaps does Neovim 0.10+ provide automatically when a language server is attached?
Starting with Neovim 0.
category:
config
tags:
#config
#navigation
#buffers
How do I prevent Vim from automatically resizing a window when others open or close?
Setting winfixwidth on a window tells Vim not to adjust its width when other windows are created, closed, or resized with =.
category:
buffers-windows
tags:
#buffers-windows
#config
#editing
#windows
How do I jump to the first macro or #define definition of the word under the cursor?
Vim's [ command jumps to the first definition of the macro or identifier under the cursor, searching from the beginning of the current file and through any file
category:
navigation
tags:
#navigation
#search
#normal-mode
How do I sort selected lines in Vim?
The :'sort command sorts the currently selected lines in visual mode alphabetically.
category:
visual-mode
tags:
#visual-mode
#ex-commands
#editing
#formatting
How do I append text to the end of multiple lines of different lengths?
When you need to append text to the end of several lines that have different lengths, visual block mode with $ is the key.
category:
visual-mode
tags:
#visual-mode
#editing
#block-mode
#insert-mode
How do I paste back a small deletion (like a deleted character) while in insert mode?
In insert mode, - pastes the contents of the small delete register ("-).
category:
registers
tags:
#registers
#insert-mode
#editing
How do I look up which two-character code produces a special character when using Vim's digraph system?
:digraphs (abbreviated :dig) displays a full reference table of every digraph registered in Vim.
category:
command-line
tags:
#editing
#special-characters
#insert-mode
#command-line
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 jump to a tag definition in a new split window instead of the current buffer?
Pressing g jumps to the definition of the tag under the cursor — just like — but opens the destination in a new horizontal split window.
category:
buffers-windows
tags:
#navigation
#buffers
#windows
#tags
How do I make the = operator format code with an external tool like gofmt or black?
By default, Vim's = operator re-indents text using its internal rules.
category:
config
tags:
#config
#editing
#ex-commands
#formatting
#indentation
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 save and automatically restore a buffer's fold state and cursor position across Vim sessions?
:mkview saves a snapshot of the current window — its fold states, cursor position, and local option values — to a view file on disk.
category:
buffers-windows
tags:
#folding
#buffers-windows
#config
#ex-commands
How do I insert a Unicode character by its codepoint in insert mode?
In insert mode, pressing followed by u and a 4-digit hexadecimal codepoint inserts the corresponding Unicode character directly into the buffer.
category:
editing
tags:
#insert-mode
#editing
#unicode
How do I control which sources Vim searches when triggering keyword completion with Ctrl-N?
The complete option controls which sources Vim scans when you press or for generic keyword completion.
category:
config
tags:
#completion
#config
#insert-mode
How do I control how many fold levels are open when first opening a file?
When Vim opens a file with folds enabled, it uses the foldlevelstart option to decide how many fold levels to open automatically.
category:
config
tags:
#folding
#config
#navigation
How do I use a macro to automatically increment a number on each line?
By recording a one-step macro that increments a number and moves down a line, you can bulk-apply across as many lines as needed with a single count.
category:
macros
tags:
#macros
#editing
#normal-mode