Dev In The Mountain Header
A Developer In The mountains having fun

Working with and using VIM marks

Marks are a quick way in vim of marking and moving to a place in the document.

Create a mark

Uppercase marknames are instance wide and lowercase are buffer/document wide. This means that if you use an uppercase letter to create a mark that when you recall it you will go back to that line in that document no matter which document you are currently in. I love this as its very quick to move around files.

m{char} - creates a mark names {char}

    example: `ma` creates a mark names "a"

Move to a mark

'{char} - moves to the line of the mark of name {char}

`{char} - moves to the line and column of the mark of name {char}

List Marks

:marks - lists all current marks

Deleting marks

if you delete a line containing a mark that mark is also deleted.

:delmarks{char} - deletes a mark of name {char}

:delmarks! - deletes all marks for the current buffer (file)

Special marks

. — jump to position where last change occurred in current buffer

" — jump to position where last exited current buffer

0 — jump to position in last file edited (when exited Vim)

1 — like 0 but the previous file (also 2 etc)

' — jump back (to line in current buffer where jumped from)

` — jump back (to position in current buffer where jumped from)

[ or ] — jump to beginning/end of previously changed or yanked text

< or > — jump to beginning/end of last visual selection

More places to find me
Mental Health
follow me on Mastodon