Automatically save Foldings in vim

Normaly you have to type allways :mkview and :loadview to save your folds, so simply add this two lines to your ~/.vimrc:

au BufWinLeave * silent! mkview
au BufWinEnter * silent! loadview

Now, each time you close a file, its fold state will be saved and reloaded when you reopen the file in Vim.

Edit:

When I open new empty files from the shell or from Vim (:new)

I get the error message:

Error detected while processing BufWinEnter Auto commands for “*”:

E32: No file name

This also happens when opening :help window and sourcing sessions with

the shell command “vim -S session.vim”. Have to find a way to run automatic :loadview only for windows that actually have a filename

Technorati Tags: , ,

~ by princ3 on January 26, 2007.

One Response to “Automatically save Foldings in vim”

  1. You crossed off the section underneath Edit, but I am still getting that error every time I open a new file, did you find a way to fix it? If so, would you mind sharing?

Leave a Reply