How do I force any window-opening command to create a vertical split instead of horizontal?
The :vertical command modifier forces any window-opening Ex command to create a vertical split instead of the default horizontal split.
category:
buffers-windows
tags:
#windows
#buffers
#command-line
#splits
#ex-commands
How do I compile a custom word list into a Vim spell file for faster spell checking?
:mkspell ~/.vim/spell/en.utf-8.add
When you add words to your personal spell file with zg, Vim writes them to a plain-text .
category:
config
tags:
#config
#search
How do I fully justify a selected text block to a fixed width using Vim's built-in justify plugin?
:packadd justify | :'<,'>Justify 72
Vim can wrap text, but full left-and-right justification is a different task.
category:
plugins
tags:
#plugins
#formatting
#visual-mode
#text-manipulation
How do I use the expression register inside a macro for dynamic values?
How it works The expression register (=) lets you evaluate Vimscript expressions and insert the result.
category:
macros
tags:
#macros
#registers
#insert-mode
How do I pass a range of lines through a shell command and replace them?
The :{range}!command syntax pipes the specified lines through an external shell command and replaces them with the output.
category:
command-line
tags:
#command-line
#shell
#filtering
#unix
#ex-commands
How do I temporarily highlight a custom text pattern in my buffer without changing the syntax file?
:match {group} /{pattern}/
:match lets you apply a highlight group to any pattern in the current window without touching the buffer or its syntax rules.
category:
config
tags:
#search
#config
#normal-mode
#ex-commands
How do I activate a configured language server in Neovim 0.11 for specific filetypes?
vim.lsp.enable('server-name')
vim.
category:
plugins
tags:
#lsp
#neovim
#plugins
#lua
How do I run a command on every line matching a pattern?
The :g/pattern/command (global) command executes an Ex command on every line in the file that matches the given pattern.
category:
command-line
tags:
#ex-commands
#search
#editing
#command-line
How do I add floating scratch buffers, a built-in file picker, and lazygit integration in Neovim using a single plugin?
snacks.
category:
plugins
tags:
#plugins
#navigation
#buffers
#terminal
How do I run a Normal-mode command through :execute in Vim?
:execute "normal! gg=G"<CR>
:execute lets you build and run Ex commands dynamically, which is critical when a command depends on variables, conditionals, or string composition.
category:
command-line
tags:
#command-line
#ex-commands
#normal-mode
#automation
How do I apply a macro only to files that appear in the current location list?
:lfdo normal! @q | update
When you already have a curated location list, :lfdo lets you apply a change only to those files instead of touching your whole project.
category:
macros
tags:
#macros
#location-list
#refactoring
#command-line
#normal-mode
How do I join a wrapped paragraph into one line without manual cursor moves?
When text is hard-wrapped for readability in git diffs or markdown source, you sometimes need the paragraph as a single line for refactoring, search, or export.
category:
editing
tags:
#editing
#visual-mode
#formatting
#text-objects
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 create a macro by typing it out instead of recording it interactively?
Recording macros with q works well for simple sequences, but complex macros with special keys can be hard to get right in one take.
category:
macros
tags:
#macros
#registers
#ex-commands
How do I automatically remove trailing whitespace every time I save a file?
autocmd BufWritePre * :%s/\s\+$//e
By adding an autocmd for the BufWritePre event, you can make Vim automatically strip trailing whitespace from every line each time you save.
category:
config
tags:
#config
#autocmd
#editing
#whitespace
#vimrc
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 save a file I opened without sudo permissions?
The :w !sudo tee % command lets you save a file that requires root permissions, even if you forgot to open Vim with sudo.
category:
command-line
tags:
#command-line
#ex-commands
#editing
How do I insert the full WORD under the cursor (including slashes and dots) into the command line?
When you are in command-line mode, inserts the word under the cursor (alphanumeric and _ only).
category:
command-line
tags:
#command-line
#editing
#registers
How do I scroll and copy text from a terminal buffer in Vim?
When using Vim's built-in :terminal, the buffer is in Terminal-Job mode by default, meaning all keystrokes go to the running shell.
category:
buffers-windows
tags:
#terminal
#buffers
#windows
#normal-mode
How do I list all lines matching a pattern across the current file and its includes?
The :ilist command searches for a pattern not only in the current buffer but also in files referenced by #include directives (or whatever 'include' is set to).
category:
search
tags:
#search
#ex-commands
#navigation
#editing