How do I use marks inside a macro to return to a specific position?
qama{edits}'aq
How it works When a macro needs to jump to different parts of the file and then return to a starting position, marks are the perfect tool.
qama{edits}'aq
How it works When a macro needs to jump to different parts of the file and then return to a starting position, marks are the perfect tool.
:'a,'b s/old/new/g
Marks can be used as range specifiers in any Ex command.
command-line #marks #command-line #ex-commands #ranges #editing
`[v`]
The ` [v] sequence visually selects the exact region of text that was last changed, pasted, or yanked into the buffer.
visual-mode #editing #visual-mode #marks #paste #productivity
gi
The gi command moves the cursor to the position where you last exited insert mode and immediately enters insert mode again.
navigation #navigation #insert-mode #marks #normal-mode #productivity
g; / g,
The g; and g, commands let you navigate Vim's changelist — a per-buffer history of every position where you made a change.
navigation #navigation #changelist #editing #normal-mode #marks
mA / 'A
Uppercase marks (A-Z) are global marks — they remember not only the line and column position, but also the file where they were set.
navigation #navigation #marks #normal-mode #buffers #productivity
` vs '
Vim offers two ways to jump to a mark, and the difference is crucial: the backtick (` `) jumps to the exact line and column where the mark was set, while the si
ma and 'a
The ma command sets a mark named a at the current cursor position.
`.
The ` .