Code folding is not saved in my vimrc

后端 未结 6 1473
伪装坚强ぢ
伪装坚强ぢ 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 08:46

    Per Jays comments this is the most elegant solution, I have a LOT of plugins and run it on multiple OSes and have just tested it.

    autocmd BufWrite * mkview
    autocmd BufRead * silent loadview
    

    It does not break MRU and make you have to double query MRU It does not error when you :new into an empty buffer It also doesn't require you to create FileType patern for every file-type you may possibly use.

    NOTE: using "loadview" on "BufNewFile" apears to be what confuses MRU, rather pointless trying to render folds on an empty buffer I would have thought??

提交回复
热议问题