How do I copy the current file's path into the system clipboard from Vim?
:let @+=@%
The % register always holds the name of the current file (as a relative path).
:let @+=@%
The % register always holds the name of the current file (as a relative path).
\%(pattern\)
In Vim's regex engine, \( and \) create a capturing group whose contents are stored in \1, \2, etc.
:keepjumps {cmd}
:keepjumps is a command modifier that suppresses any jump list updates caused by the command that follows it.
:bufdo {cmd}
:bufdo executes an Ex command in each open buffer in sequence, cycling through every buffer in the buffer list.
:cdo {cmd}
:cdo executes an Ex command on every entry in the quickfix list in sequence, visiting each match in turn.
: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
:set switchbuf=useopen
The switchbuf option controls how Vim decides where to display a buffer when switching to it via commands like :sb, :cc, :cn, quickfix jumps, or .
buffers-windows #buffers-windows #navigation #ex-commands #config
:normal!
The :normal! command (with !) executes normal mode keystrokes exactly as Vim defines them, ignoring any user-defined mappings.
:set keywordprg=:help
By default, pressing K in Normal mode runs the word under the cursor through an external program — usually man.
:m.+1 and :m.-2
The :move (:m) command relocates a line to a new position without cutting and pasting.
:let @q = @:
The : register always holds the last Ex command you ran.
:%s/\w\+/(&)/g
In a Vim substitution, & in the replacement string expands to the entire matched text.
:messages
:messages displays the full log of recent Vim messages — errors, warnings, echo output, and status notifications.
:setlocal {option}={value}
:setlocal sets an option only for the current buffer or window, leaving all other buffers and windows unaffected.
!{motion} {cmd}
The ! operator passes text selected by a motion through an external shell command, replacing it with the command's output.
:%s/\(\w\+\)/\u\L\1/g
Vim's substitute command supports case-conversion escape sequences in the replacement string.
:set diffopt+=algorithm:patience,indent-heuristic
By default, Vim uses a basic longest-common-subsequence diff algorithm that can produce noisy, hard-to-read diffs.
:args **/*.js
The :args command populates Vim's argument list with files matching a glob pattern, turning any set of files into a navigable list and enabling project-wide bat
<C-r>={expr}<CR>
The expression register ("=) lets you evaluate any Vimscript expression and insert the result directly into the buffer — all without leaving insert mode.
:s/\v(\w+) (\w+)/\2 \1/
Vim's substitute command supports capture groups using \( and \) (or ( and ) in \v very-magic mode).