How do I quickly insert the current file's directory into a command-line prompt without typing the full path?
:cnoremap %% <C-r>=expand('%:h').'/'<CR>
By mapping %% in command-line mode, you can type %% wherever you would normally type a path and have Vim automatically expand it to the directory of the current
category:
config
tags:
#command-line
#ex-commands
#navigation
#config
How do I insert the entire current line into the command line without typing it?
Pressing on the command line inserts the full text of the current buffer line (the line the cursor is on when you pressed :) directly at the command-line cursor
category:
command-line
tags:
#command-line
#editing
#navigation
How do I see all recent Vim messages, errors, and echo output I may have missed?
:messages displays the full log of recent Vim messages — errors, warnings, echo output, and status notifications.
category:
command-line
tags:
#ex-commands
#command-line
How do I open a file and automatically jump to the first line matching a pattern?
The +{cmd} flag on :edit (and most file-opening commands) runs an Ex command immediately after the file loads.
category:
command-line
tags:
#command-line
#ex-commands
#navigation
#search
#buffers
How do I run a dynamically constructed Ex command or pass special keys to :normal?
:execute evaluates a string as an Ex command, letting you build commands dynamically or embed special key sequences (like or ) as literal characters.
category:
command-line
tags:
#ex-commands
#command-line
#macros
#config
How do I insert the output of any Vim Ex command directly into the current buffer?
The :put =execute('{cmd}') idiom inserts the output of any Vim Ex command as text in your buffer.
category:
registers
tags:
#registers
#ex-commands
#command-line
#normal-mode
How do I make Tab trigger wildmenu completion inside a custom mapping?
By default, pressing in a : mapping inserts a literal tab character rather than triggering wildmenu completion.
category:
config
tags:
#config
#ex-commands
#completion
#command-line
How do I use search patterns to define the start and end of an Ex command range?
Ex command ranges in Vim are not limited to line numbers and marks — you can use /pattern/ as a range boundary to select lines between any two matching patter
category:
command-line
tags:
#ex-commands
#search
#command-line
#editing
How do I run a substitution across multiple files using Vim's argument list?
:argdo {cmd} executes an Ex command against every file in the argument list—the set of files you opened Vim with or set explicitly with :args.
category:
command-line
tags:
#command-line
#ex-commands
#editing
#buffers
How do I use a Vim expression as the replacement string in a :s substitution?
Vim's :s command normally replaces matches with a literal string.
category:
command-line
tags:
#search
#editing
#ex-commands
#command-line
#registers
How do I programmatically load text or a macro into a named register from the command line?
:let @{register}=".
category:
registers
tags:
#registers
#macros
#command-line
#vimscript
How do I use a Vimscript expression to compute the replacement text in a substitution?
Prefixing the replacement field of :s with \= makes Vim evaluate the rest as a Vimscript expression and use the result as the replacement string.
category:
command-line
tags:
#search
#ex-commands
#editing
#command-line
How do I open a file and jump directly to a specific line or pattern?
The :edit command accepts a +{cmd} prefix that executes an Ex command immediately after the file is loaded.
category:
command-line
tags:
#buffers
#ex-commands
#navigation
#command-line
How do I search for a pattern across all files in my project with Vim's built-in grep?
:vimgrep /pattern/ (shortened to :vim) is Vim's built-in project-wide search.
category:
command-line
tags:
#search
#ex-commands
#navigation
#command-line
How do I open a related file with a different extension using the current filename?
In Vim's command line, % expands to the current buffer's filename.
category:
command-line
tags:
#ex-commands
#command-line
#buffers
#navigation
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 open a split window that spans the full width or height of the editor instead of splitting only the current window?
When you split a window with :split or :vsplit, Vim subdivides only the current window.
category:
buffers-windows
tags:
#buffers
#windows
#ex-commands
#command-line
How do I view my complete Vim command and search history?
:history displays a numbered list of your recently entered Ex commands, giving you a full audit of what you have run in the current session (and across sessions
category:
command-line
tags:
#ex-commands
#command-line
#search
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 replace a line (or range) with the output of a shell command in Vim?
:.
category:
command-line
tags:
#ex-commands
#editing
#command-line