How do I show both the absolute line number on the current line and relative numbers on all other lines?
:set number relativenumber
Enabling both number and relativenumber simultaneously activates hybrid line numbering: the current line displays its true absolute line number while every othe
category:
config
tags:
#config
#navigation
#normal-mode
#editing
How do I customize Vim's statusline to show useful file information?
:set statusline=%f\ %y\ [%l/%L]
Vim's statusline option lets you build a custom status bar from format items.
category:
config
tags:
#config
#formatting
How do I comment out all lines matching a pattern at once using vim-commentary?
vim-commentary exposes Commentary as an Ex command that toggles comments on the current line, making it composable with Vim's :global command.
category:
plugins
tags:
#plugins
#vim-commentary
#ex-commands
#editing
How do I revert a file to its state from a specific time ago?
:earlier {time} / :later {time}
Vim's :earlier and :later commands let you navigate the undo history by wall-clock time rather than by individual undo steps.
category:
editing
tags:
#editing
#undo-redo
#ex-commands
#advanced
#productivity
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 view all symbols in the current file using Neovim's built-in LSP?
Since Neovim 0.
category:
plugins
tags:
#lsp
#neovim
#navigation
#symbols
#plugins
How do I restrict a Vim search to match only within a specific range of line numbers?
Vim's \%>{lnum}l and \%5l — matches only at positions after line 5 (i.
category:
search
tags:
#search
#regex
#navigation
#ex-commands
How do I rename a symbol under the cursor using Neovim's built-in LSP without any plugin configuration?
Since Neovim 0.
category:
plugins
tags:
#lsp
#neovim
#navigation
#rename
#code-action
How do I show context lines around each match when using the :global command?
The :global command is great for finding lines matching a pattern, but by default it only shows the matching lines themselves.
category:
command-line
tags:
#search
#ex-commands
#navigation
#command-line
How do I highlight a custom pattern with a priority so it wins over other overlapping highlights?
matchadd('Group', 'pattern', priority)
matchadd() accepts an optional third argument: a priority integer that controls which match wins when two patterns cover the same text.
category:
config
tags:
#config
#search
#normal-mode
How do I browse through my previous quickfix lists?
Vim remembers up to 10 previous quickfix lists.
category:
buffers-windows
tags:
#buffers
#quickfix
#navigation
#history
How do I assign a macro to a register directly from the command line without recording it?
You can assign a string directly to any register using :let @{reg} = '.
category:
macros
tags:
#macros
#registers
#ex-commands
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 create custom folds to collapse specific sections of code?
Vim supports several fold methods, but manual folding with zf gives you precise control over exactly which lines to collapse.
category:
editing
tags:
#folding
#normal-mode
#visual-mode
#editing
How do I execute a recorded macro a specific number of times?
Prefix the @ macro-execution command with a count to run the macro that many times in a row.
category:
macros
tags:
#macros
#registers
#normal-mode
#editing
How do I jump back to locations where I previously made edits?
Vim tracks every position where you made a change in the changelist.
category:
navigation
tags:
#navigation
#editing
#normal-mode
#motions
How do I copy a line to another location without using yank and paste?
How it works The :t command (short for :copy) copies one or more lines and places them below the specified address.
category:
editing
tags:
#editing
#ex-commands
#normal-mode
How do I make Vim preserve the cursor column when jumping between lines?
By default, many Vim movement commands — gg, G, Ctrl-d, Ctrl-u, Ctrl-f, Ctrl-b, and others — snap the cursor to the first non-blank character of the destina
category:
config
tags:
#navigation
#config
#motions
#normal-mode
How do I add custom markers or icons in Vim's sign column next to specific lines without any plugins?
:sign define and :sign place
Vim's built-in sign system lets you define custom symbols and place them in the sign column — the narrow gutter to the left of line numbers.
category:
command-line
tags:
#command-line
#ex-commands
#vimscript
How do I view the git history for the current file as a navigable quickfix list using vim-fugitive?
Running :Gclog in vim-fugitive loads the git log for the current file into the quickfix list.
category:
plugins
tags:
#plugins
#git
#buffers
#quickfix