How do I open or edit a file in the same directory as the file I am currently editing?
:e %:h/
Vim expands % to the current file's path in Ex commands, and the :h modifier strips the last filename component to give you just the directory.
2277 results for "@a"
:e %:h/
Vim expands % to the current file's path in Ex commands, and the :h modifier strips the last filename component to give you just the directory.
S"
The vim-surround plugin provides the S command in visual mode to wrap any selection with a delimiter pair.
\{-}
In Vim's regex engine, \{-} is the non-greedy (lazy) quantifier — it matches as few characters as possible, unlike .
<C-v>jjlU
Visual block mode lets you select rectangular regions of text, which means you can target a specific column and apply case changes only to that area.
%:t:r
Vim's % special character expands to the current filename and accepts a chain of colon-delimited modifiers.
command-line #command-line #ex-commands #editing #navigation
gf
The gf command ("go to file") opens the file whose path is under the cursor.
navigation #navigation #normal-mode #buffers #productivity #file-management
:ce
Vim has three built-in ex commands for text alignment that most users never discover: :ce (center), :ri (right-justify), and :le (left-justify).
gaip=
vim-easy-align is a plugin by Junegunn Choi that makes aligning text around delimiters effortless.
:'<,'>normal! .
When you already made one correct edit, replaying it is usually safer than retyping it by hand.
:silent keeppatterns %s/\s\+$//e
Trailing whitespace cleanup is a common housekeeping step, but a plain substitution can leave side effects: it can overwrite your last search pattern (@/) and t
command-line #command-line #ex-commands #editing #search #formatting
:set verbosefile=/tmp/vim.log verbose=9
Vim's verbosefile option redirects all verbose tracing output to a file on disk instead of printing it to the screen.
:%Subvert/old{,s}/new{,s}/g
Tim Pope's vim-abolish plugin provides the :Subvert command (aliased as :S), which performs substitutions that automatically preserve case variants and handle p
plugins #plugins #substitution #editing #ex-commands #search
g?
Vim has a built-in ROT13 encoding operator accessible via g?.
visual-mode #visual-mode #encoding #rot13 #text-transformation
ciw""<Esc>P
Vim doesn't have a built-in "surround" operator, but you can wrap any word in quotes or brackets with a short sequence: ciw""P.
editing #editing #text-objects #normal-mode #productivity #surround
:s/\(\w\+\)/\u\1/g
Vim's substitute command supports case-change modifiers in the replacement string that let you capitalize, uppercase, or lowercase matched text as part of the s
:lockmarks keepjumps keeppatterns %s/foo/bar/ge
Large substitutions are efficient, but they often leave side effects: your last search changes, your jumplist gets noisy, and marks can shift in ways that break
command-line #command-line #editing #substitution #navigation
/\(function\s\+\)\zs\w\+
Vim's \zs and \ze atoms let you control which part of a matched pattern gets highlighted and operated on.
zi
Pressing zi in normal mode toggles the foldenable option, which controls whether folds are active in the current window.
:packadd {name}
Vim 8+ and Neovim have a built-in package manager.
<Cmd>
The pseudo-key in Neovim allows a mapping to execute an Ex command directly, without going through command-line mode.