Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

in vim, is there a way to save bookmarks between sessions?

when exiting vim and then re-entering, all bookmarks have gone

have found out how to remember last position between files, but not how to remember bookmarks after having exited.

is there a way to configure vim so that bookmarks are remembered for a file?

like image 908
cc young Avatar asked Jan 22 '12 00:01

cc young


People also ask

How do I create a bookmark in Vim?

To set a mark, type m followed by a letter. For example, ma sets mark a at the current position (line and column). If you set mark a, any mark in the current file that was previously identified as a is removed. If you set mark A, any previous mark A (in any file) is removed.

How do I save a Vim session?

To Save a Session ( :mksession , :mks )vim file on the directory where the current Vim execution was started. Using exclamation mark, :mks! the command overwrites Session. vim file if it exists in the directory. You can specify a custom file name to save the session :mks!

How do I save a workspace in Vim?

You can save the current session (or buffer layout) by giving the command :Obsession . If you don't supply an argument, it writes a session file called Session. vim by default. To reload a session, either use vim -S <session-name> or :source <session-name> if you're inside Vim already.


1 Answers

Yes. Add the following to your .vimrc:

:set viminfo='1000,f1

But note:

Lowercase marks 'a to 'z are remembered as long as the file remains in the buffer list. If you remove the file from the buffer list, all its marks are lost. If you delete a line that contains a mark, that mark is erased.

So you'll need to use uppercase or numeric marks.

See:

  • :he 21.3
  • :he E20

...for more information.

You may also find :mksession useful if you want to save session state.

like image 134
Johnsyweb Avatar answered Sep 16 '22 15:09

Johnsyweb