How do I view the first macro or keyword definition without leaving my current position?
The [d command searches from the beginning of the file for the first line matching the define pattern for the word under the cursor, and displays it in the stat
category:
search
tags:
#search
#navigation
#normal-mode
How do I convert a file from Windows CRLF to Unix LF line endings in Vim?
When you open a Windows file in Vim on a Unix system, you may see ^M at the end of every line — that's the carriage return (\r) from CRLF line endings.
category:
editing
tags:
#editing
#config
#ex-commands
How do I navigate between multiple quickfix lists from previous searches or builds?
Vim maintains a history stack of up to 10 quickfix lists.
category:
buffers-windows
tags:
#buffers-windows
#navigation
#ex-commands
#search
How do I make the = operator use an external formatter instead of Vim's built-in indentation?
The equalprg option replaces Vim's built-in = indentation operator with any external formatting program.
category:
config
tags:
#config
#indentation
#formatting
#ex-commands
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 a file and automatically create missing parent directories in Neovim?
Neovim's :w ++p flag automatically creates any missing intermediate directories when writing a file.
category:
command-line
tags:
#command-line
#neovim
#file-handling
#workflow
How do I reopen the current file with a different character encoding in Vim?
When Vim opens a file with the wrong encoding — producing garbled text or incorrect characters — you can reload it with a specific encoding using :e ++enc={
category:
editing
tags:
#editing
#encoding
#command-line
#file-handling
How do I switch back to the previous working directory in Vim?
The :cd - command switches Vim's global working directory back to the previous one, just like cd - in the shell.
category:
command-line
tags:
#command-line
#navigation
#workflow
How do I define custom fold marker strings instead of the default {{{ }}} in Vim?
:set foldmarker=region,endregion
When using foldmethod=marker, Vim looks for the strings in foldmarker to identify fold boundaries.
category:
config
tags:
#folding
#config
#editing
How do I reuse the last visual selection range in an Ex command after exiting visual mode in Vim?
Vim automatically sets two special marks whenever you make a visual selection: ' (end).
category:
visual-mode
tags:
#visual-mode
#marks
#ex-commands
#navigation
How do I capture Vim command output to a variable or register using the execute() function?
:let @a = execute('messages')
The execute() function (added in Vim 8.
category:
command-line
tags:
#ex-commands
#registers
#macros
#command-line
How do I write a file in Vim without triggering BufWritePre or other write autocmds?
The :noautocmd modifier runs any Ex command while suppressing all autocmd events for its duration.
category:
config
tags:
#config
#ex-commands
#editing
#normal-mode
How do I center or right-align text within a specific column width in Vim?
Vim has three built-in Ex commands for aligning text without any plugins: :left, :center, and :right.
category:
editing
tags:
#editing
#formatting
#ex-commands
#visual-mode
What built-in LSP keymaps does Neovim 0.10+ provide automatically when a language server is attached?
Starting with Neovim 0.
category:
config
tags:
#config
#navigation
#buffers
How do I run a macro as many times as needed until it hits an error and stops automatically in Vim?
Vim macros stop executing the moment any step in the macro causes an error — a failed search, a motion that cannot proceed, or a substitution with no matches.
category:
macros
tags:
#macros
#editing
#normal-mode
How do I make j and k navigate display lines normally but physical lines when given a count?
nnoremap <expr> j v:count == 0 ? 'gj' : 'j'
By default, j and k move by physical lines (newline-delimited), which jumps over the entire visual span of a long wrapped line in a single keystroke.
category:
config
tags:
#navigation
#config
#motions
#normal-mode
How do I open any file in a project by partial name without a fuzzy finder plugin in Vim?
Vim's built-in :find command supports recursive glob patterns, making it possible to locate and open files anywhere in a project without installing a fuzzy find
category:
navigation
tags:
#navigation
#ex-commands
#buffers
#completion
How do I reflow or hard-wrap a paragraph to a set text width in Vim?
The vipgq sequence reflowing a paragraph to fit within the width defined by textwidth (default 0, meaning no limit).
category:
visual-mode
tags:
#visual-mode
#editing
#formatting
#text-objects
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 control which sources Vim searches when triggering keyword completion with Ctrl-N?
The complete option controls which sources Vim scans when you press or for generic keyword completion.
category:
config
tags:
#completion
#config
#insert-mode