How do I bookmark a position in one file and jump back to it from any other file?
mA to set, 'A to jump
Uppercase marks (A–Z) are global marks — they persist across files and Vim sessions.
2125 results for "i( a("
mA to set, 'A to jump
Uppercase marks (A–Z) are global marks — they persist across files and Vim sessions.
s/pattern/\r/
In Vim substitutions, \r in the replacement string inserts a line break, creating a new line.
:e %:r.html
In Vim's command line, % expands to the current buffer's filename.
command-line #ex-commands #command-line #buffers #navigation
:'<,'>retab!
The :retab! command converts between tabs and spaces based on your expandtab setting.
:let @q .= 'j'
Re-recording a long macro just to add one extra keystroke is wasteful and error-prone.
:sfind {file}
:sfind (split-find) searches Vim's path setting for a file matching the given name and opens it in a new horizontal split, all in one command.
<C-t>
The command pops the tag stack and returns to the position from which you last used or :tag.
qabi"<Esc>ea"<Esc>wq
How it works This macro wraps the current word in double quotes and moves to the next word, making it easy to repeat across a line or file.
:nnoremap <leader>d "=strftime('%Y-%m-%d')<CR>p
The expression register (=) evaluates Vimscript expressions and uses the result as register content.
:s/\%#\k\+/REPL/
Most substitutions operate on broad ranges, but sometimes you want a precise edit anchored to where your cursor is right now.
:set nrformats-=octal\<CR>
If you work with IDs, ticket numbers, or zero-padded counters, Vim's default octal behavior can be surprising.
:norm
:normal (abbreviated :norm) executes a sequence of normal-mode keystrokes on each line of an address range.
:echo strtrans(@q)
When a macro behaves unexpectedly, :echo strtrans(@q) reveals exactly what is stored in register q—including invisible control characters—as human-readable
vipgq
The vipgq sequence reflowing a paragraph to fit within the width defined by textwidth (default 0, meaning no limit).
:tab sbuffer {bufnr}<CR>
If a file is already loaded as a buffer, reopening it with :tabedit can trigger another read and may lose the exact in-memory context you want.
:keepmarks %s/pattern/replacement/g
The :keepmarks modifier prevents Vim from adjusting mark positions when a buffer-modifying command runs.
\%(pattern\)\@=
Vim's lookahead assertion \@= confirms that the current position is followed by a pattern — without including those characters in the match.
<C-v>{motion}$A
In visual block mode, pressing $ makes the right edge of the selection "ragged" — it extends to the real end of each line regardless of length.
*NgUgn
gn is often treated as a visual selection command, but it is more powerful when used as a motion target for operators.
:set switchbuf=useopen,usetab,newtab
When jump commands open files (:tag, quickfix navigation, location list jumps), Vim may split your layout in ways that break flow.