Setting a VIM bookmark

Capital letters let you set global bookmarks (i.e. in all buffers/tabs).

So you can use mA to set global bookmark A, then use 'A to get to that bookmarked place even if you're editing a different file.


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 exampleA) 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

Reference from Vim Wiki


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

enter image description here

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

source

Tags:

Vi

Vim

Bookmarks