How do I evaluate and pretty-print a Lua expression from the Neovim command line without writing print(vim.inspect(...))?
In Neovim, :lua = expr is a shorthand that evaluates a Lua expression and pretty-prints the result using vim.
category:
command-line
tags:
#neovim
#lua
#command-line
#debugging
How do I append a range of lines from the current buffer to another file in Vim?
:[range]write >> filename
The >> modifier on :write appends lines to a file instead of overwriting it.
category:
command-line
tags:
#command-line
#ex-commands
#file-handling
#editing
How do I save and restore the current window layout after temporarily changing window sizes in a Vim script?
The winrestcmd() function returns a string of Ex commands that, when executed, restore all window sizes to their state at the time of the call.
category:
config
tags:
#config
#vimscript
#windows
How do I move a line or range of lines to a different location in the file?
How it works The :m command (short for :move) moves one or more lines to after the specified address.
category:
editing
tags:
#editing
#ex-commands
#normal-mode
How do I run a command without showing its output?
The :silent prefix suppresses all output from a command, including messages and prompts.
category:
command-line
tags:
#command-line
#ex-commands
How do I land the cursor a few lines above or below a search match?
Vim's search command accepts an offset after the pattern that shifts where the cursor lands relative to the match.
category:
search
tags:
#search
#navigation
#motions
#regex
#advanced
How do I apply a recorded macro to a specific set of files using the argument list?
:argdo execute 'normal @q' | update
:argdo runs an Ex command on every file in Vim's argument list (the arglist).
category:
macros
tags:
#macros
#ex-commands
#editing
How do I delete all lines matching a pattern?
The :g/pattern/d command deletes every line in the file that matches the given pattern.
category:
command-line
tags:
#search
#ex-commands
#editing
#command-line
How do I configure a custom word list file for Vim spell checking so I can persist accepted words?
By default, when you use zg to add a word to Vim's spell-check dictionary, it is saved in a file in your Vim data directory.
category:
config
tags:
#config
#spell
#completion
How do I make the tilde key work as a case-toggle operator so I can use motions like ~w or ~ip?
By default, ~ toggles the case of a single character and advances the cursor.
category:
config
tags:
#editing
#config
#normal-mode
How do I define or edit a macro's content programmatically without re-recording it?
You can assign a string directly to any register using :let, turning it into a macro instantly.
category:
macros
tags:
#macros
#registers
#vimscript
#normal-mode
How do I choose from multiple tag matches when a tag has several definitions?
When a tag has multiple definitions (e.
category:
navigation
tags:
#navigation
#ex-commands
How do I collapse every tab page to a single window without closing tabs?
When you are deep in a refactor, each tab can accumulate helper splits, previews, and temporary views.
category:
buffers-windows
tags:
#buffers
#windows
#tabs
#ex-commands
#workflow
How do I preview a function or tag definition without leaving my current position?
How it works The } command opens a preview window showing the tag definition of the word under your cursor.
category:
buffers-windows
tags:
#windows
#navigation
#normal-mode
How do I group regex atoms in Vim without creating a backreference?
In Vim's regex engine, \( and \) create a capturing group whose contents are stored in \1, \2, etc.
category:
search
tags:
#search
#regex
#ex-commands
#normal-mode
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 control exactly where a new split window appears in Vim?
By default, Vim places horizontal splits below and vertical splits to the right (controlled by splitbelow and splitright).
category:
buffers-windows
tags:
#buffers
#windows
#ex-commands
#splits
How do I close a buffer without closing the window?
The :bp bd # command switches to the previous buffer and then deletes the alternate buffer.
category:
buffers-windows
tags:
#buffers
#windows
#ex-commands
How do I switch to a specific buffer by number?
The :b command followed by a buffer number switches directly to that buffer.
category:
buffers-windows
tags:
#buffers
#ex-commands
How do I execute Ctrl-W window commands from the command line or a Vimscript function?
:wincmd {key} executes any {key} window command from the Ex command line or from inside a Vimscript function.
category:
buffers-windows
tags:
#windows
#ex-commands
#buffers-windows