Code folding is not saved in my vimrc

后端 未结 6 1470
伪装坚强ぢ
伪装坚强ぢ 2021-02-07 08:25

I added the following code to my .vimrc:

\" save and restore folds when a file is closed and re-opened
autocmd BufWinLeave *.* mkview
autocmd BufWinEnter *.* sil         


        
6条回答
  •  遥遥无期
    2021-02-07 09:01

    Add this to the top of your vimrc to make sure the viewdir is present

    let &viewdir=expand("$HOME") . "/.bk/.vim/viewdir"
    if !isdirectory(expand(&viewdir))|call mkdir(expand(&viewdir), "p", 451)|endif
    

    Then this in your autocmds section:

    autocmd BufWrite * mkview
    autocmd BufNewFile,BufRead * silent loadview
    

提交回复
热议问题