How do I persistently highlight a pattern in Vim using a specific highlight group without a plugin?
:match, :2match, and :3match give you three independent highlight slots that overlay patterns on the buffer using any highlight group — without touching the s
category:
search
tags:
#search
#config
#normal-mode
#ex-commands
How do I configure :make to run the current file as a script with a specific interpreter?
Setting makeprg to include % lets :make always execute the file you're currently editing.
category:
config
tags:
#config
#makeprg
#workflow
#quickfix
How do I sort lines while ignoring a leading prefix like a key or label?
The :sort /{pattern}/ command sorts lines by their content after the first match of the pattern.
category:
command-line
tags:
#editing
#ex-commands
#command-line
How do I reverse the order of lines in a file or selection?
Vim doesn't have a built-in reverse command, but you can pipe the buffer through tac (reverse of cat) to flip line order.
category:
editing
tags:
#editing
#reverse
#lines
#external-command
How do I open a specific buffer in a new split without navigating away from my current buffer?
:sbuffer {N} opens buffer number N in a new horizontal split, leaving your current window untouched.
category:
buffers-windows
tags:
#buffers-windows
#buffers
#windows
#navigation
How do I save a file under a new name in Vim?
The :saveas {filename} command writes the current buffer to a new file and makes that new file the current buffer's file.
category:
command-line
tags:
#ex-commands
#editing
How do I add Emacs-style editing shortcuts to Vim's command line?
Vim's command line has limited navigation by default.
category:
command-line
tags:
#command-line
#mapping
#cnoremap
#editing
How do I open a file and immediately execute a command, like jumping to a pattern or line?
The :e +{cmd} {file} form opens a file and executes an Ex command immediately after loading it.
category:
command-line
tags:
#ex-commands
#buffers
#editing
How do I replace a text object with the contents of a register in Neovim 0.11?
Neovim 0.
category:
editing
tags:
#editing
#registers
#text-objects
#normal-mode
How do I check whether a register contains characterwise, linewise, or blockwise text?
The getregtype() function returns the motion type of a register's content — whether it was yanked characterwise, linewise, or as a visual block.
category:
registers
tags:
#registers
#ex-commands
#macros
How do I automatically apply the preferred LSP code action without a selection prompt in Neovim?
vim.lsp.buf.code_action({ apply = true, filter = function(a) return a.isPreferred end })
When an LSP server marks a code action as isPreferred (e.
category:
plugins
tags:
#normal-mode
#ex-commands
How do I inspect the current contents of a specific register before pasting or running it as a macro?
The :reg {name} command displays the current contents of one or more named registers in a formatted listing.
category:
registers
tags:
#registers
#macros
#debugging
How do I jump to a tag definition using the tag stack?
The command jumps to the definition of the keyword under the cursor using tag files.
category:
navigation
tags:
#navigation
#ex-commands
#normal-mode
How do I edit an existing macro by modifying its register text instead of rerecording it?
:let @q = substitute(@q, '\n$', 'A;<Esc>\n', '')
Rerecording a long macro for one tiny change is slow and error-prone.
category:
macros
tags:
#macros
#registers
#automation
#vimscript
How do I run a command on every open buffer?
The :bufdo command executes an Ex command on every buffer in the buffer list.
category:
buffers-windows
tags:
#buffers
#ex-commands
How do I make the Neovim jump list behave like a browser history stack instead of a ring?
By default Vim's jump list is a ring: if you press to go back several positions and then make a new jump, the list wraps around and future entries are preserved
category:
navigation
tags:
#navigation
#jump-list
#config
How do I temporarily set a Vim option?
The :set command changes Vim options for the current session.
category:
command-line
tags:
#command-line
#config
#ex-commands
How do I prevent a window from switching to a different buffer in Neovim?
Neovim's winfixbuf option (added in Neovim 0.
category:
buffers-windows
tags:
#neovim
#buffers
#windows
#config
How do I replace text using a custom Vimscript function in a substitution?
:%s/pattern/\=MyFunc(submatch(0))/g
The \= prefix in Vim's substitute replacement invokes the expression register, which can call any Vimscript function.
category:
search
tags:
#search
#substitute
#vimscript
#functions
#advanced
How do I restrict a search to only match within a specific line range?
Vim's \%>Nl and \%10l matches only after line 10 \%10l\%10l\%<20lold/new/g Combine with column restrictions for precise region targeting Tips Line numbers in \%
category:
search
tags:
#search
#regex
#range
#line-numbers