How do I count the number of pattern matches in a file without making substitutions?
The :s///gn command counts how many times a pattern appears in the file without actually replacing anything.
category:
command-line
tags:
#search
#ex-commands
#substitution
#command-line
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 set buffer-local keymaps that only activate when an LSP server attaches to a buffer in Neovim?
vim.api.nvim_create_autocmd('LspAttach', ...)
Setting your LSP keymaps inside a LspAttach autocmd ensures they are only active in buffers where a language server is actually running.
category:
config
tags:
#lsp
#neovim
#config
#autocmd
#keymaps
How to configure what Neovim saves between sessions using the ShaDa file?
Neovim's ShaDa (Shared Data) file replaces Vim's viminfo and persists session state across restarts — marks, registers, command history, search history, jump
category:
config
tags:
#config
#navigation
#registers
#ex-commands
How do I completely remove a buffer from Vim?
The :bwipeout command (:bw) completely removes a buffer from Vim's memory, including its marks, options, and variables.
category:
buffers-windows
tags:
#buffers
#ex-commands
How do I create a new empty buffer?
The :enew command creates a new unnamed empty buffer in the current window.
category:
buffers-windows
tags:
#buffers
#windows
#ex-commands
How do I view all available branches in Vim's undo tree to recover changes that u and Ctrl-R can't reach?
Vim's undo history is a tree, not a linear stack.
category:
editing
tags:
#undo-redo
#editing
#command-line
How do I hide a buffer from the buffer list without closing it?
Setting nobuflisted removes a buffer from the :ls output and buffer-switching commands like :bnext/:bprev, while keeping it loaded and accessible.
category:
buffers-windows
tags:
#buffers-windows
#buffers
#unlisted
#management
How do I open an existing buffer in a new split window?
The :sb (short for :sbuffer) command opens a buffer that is already loaded in Vim in a new horizontal split window.
category:
buffers-windows
tags:
#buffers
#windows
#ex-commands
How do I fuzzy-search and switch between open buffers in Vim?
The fzf.
category:
plugins
tags:
#plugins
#fzf
#buffers
#navigation
#workflow
How do I programmatically get the count of diagnostics by severity in Neovim Lua?
vim.
category:
config
tags:
#lsp
#neovim
#config
#diagnostics
#statusline
How do I open another buffer in a split without changing the alternate-file register?
The alternate-file register (#) is easy to disturb when jumping around buffers, and many advanced motions depend on it (, # expansions, quick two-file toggles).
category:
buffers-windows
tags:
#buffers
#windows
#command-line
#navigation
How do I zero-pad numbers with :substitute using an expression replacement?
:%s/\v(\d+)/\=printf('%04d', submatch(1))/g<CR>
When you need to normalize IDs, ticket numbers, or sequence values, :substitute can do more than plain text replacement.
category:
command-line
tags:
#command-line
#substitute
#regex
#formatting
#ex-commands
How do I find out which file or plugin last set a particular Vim option?
:verbose set {option}? shows the current value of an option and reports exactly which file set it last — the full path and line number.
category:
command-line
tags:
#command-line
#config
#ex-commands
How do I read or modify the lines of a buffer that is not currently displayed without switching to it?
getbufline() / setbufline()
The getbufline() and setbufline() functions let you inspect and update any loaded buffer's contents from Vimscript without switching the active window.
category:
buffers-windows
tags:
#buffers-windows
#ex-commands
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 execute Lua code directly from the Neovim command line without writing a script file?
Neovim's :lua command lets you run arbitrary Lua code inline from the command line.
category:
command-line
tags:
#command-line
#lua
#neovim
#vimscript
#advanced
How do I view the list of positions where I made edits in Vim?
How it works Vim maintains a change list that records the position of every change you make to a buffer.
category:
navigation
tags:
#navigation
#ex-commands
#normal-mode
How do I switch to the next buffer in Vim?
The :bnext (or :bn for short) command switches to the next buffer in Vim's buffer list.
category:
buffers-windows
tags:
#buffers
#ex-commands
#navigation
How do I export my syntax-highlighted Vim buffer to an HTML file?
The :TOhtml command converts the current buffer — complete with its syntax highlighting colors — into a standalone HTML file.
category:
command-line
tags:
#ex-commands
#command-line
#editing