How you can set a bookmark in vim? I want to bookmark some lines and functions. How do you make a bookmark on the code? My code is written in C.
3 Answers
If you type ma
, it will create bookmark on the current line at the current location with name a
.
for example, typing ma
has created a bookmark at the exact location where the cursor is highlighted
To Access Bookmarked Line Inside Vi you can use - {macro-name}
backtick followed by the macro name. Move to the exact bookmark location. This will jump to the exact character location within the line from where it was bookmarked earlier.
For example, if you type `a , it will take you to the bookmark with name “a”. i.e It will take you to the place where the cursor is high-lighted in the above Fig 1.
`a

- 1,717
- 1
- 27
- 42
-
6looks like the backtick goes to the exact spot on the line, while the single quote goes to the beginning of the line. – JBaczuk Aug 16 '19 at 14:11
-
1
-
1To delete bookmarks execute `:delmarks {bookmark-name}` e.g. `:delmarks a`. Found that [here](https://www.tutorialspoint.com/vim/vim_markers.htm). – Viesturs Knopkens Aug 11 '22 at 11:38
To jump to a mark enter an apostrophe (') or backtick (`) followed by a letter. Using an apostrophe jumps to the beginning of the line holding the mark, while a backtick jumps to the line and column of the mark.
Using a lowercase letter (for example `a) will only work if that mark exists in the current buffer. Using an uppercase letter (for example `A) will jump to the file and the position holding the mark (you do not need to open the file prior to jumping to the mark).
- Each file can have mark a – use a lowercase mark to jump within a file.
- There is only one file mark A – use an uppercase mark to jump between files.
Command Description
ma set mark a at current cursor location
'a jump to line of mark a (first non-blank character in line)
`a jump to position (line and column) of mark a
d'a delete from current line to line of mark a
d`a delete from current cursor position to position of mark a
c'a change text from current line to line of mark a
y`a yank text to unnamed buffer from cursor to position of mark a
:marks list all the current marks
:marks aB list marks a, B

- 91,433
- 48
- 218
- 260

- 921
- 9
- 12
-
Love the single quote instead of the tick... the tick is awkward when you go keyboard-only. – Saturn K Dec 30 '20 at 16:56