brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: ma sets a mark in Vim and 'a jumps back to it

Vim
~/tips/tip-vim-marks

ma

Bookmarks a spot in a file so you can return to it.

When you need to look something up further down and come back, I find a mark quicker than remembering a line number.

ma
'a
`a

ma sets mark a at the cursor. Any lowercase letter works, so you have 26 per file. 'a jumps to the start of that line, and `a (backtick) to the exact column.

Marks also work as ranges and motions. d'a deletes from the current line to the mark, and this sorts everything between two marks:

:'a,'bsort

Uppercase marks are global. mA in your vimrc and 'A from anywhere else opens that file and jumps there. One on your notes file is a nice shortcut.

A few marks are set for you: '' goes back to the line before your last jump, '. to the last change, and '" to where you were when you last left the file.

:marks lists all of them. Lowercase marks move along when you add or remove lines above them, but deleting the line that holds a mark deletes the mark too.

Further reading: Vim help: marks

Going deeper: Guide: advanced tmux, a config that grows with you, formats, layouts and more

More Vim tips :%s/<Ctrl-r><Ctrl-w>/newname/g /oldname find . -name "*.conf" | vim – vim --clean file.txt :set textwidth=72 All Vim tips (45) All topics

Link