fold nvim code example

Example: Make folding views neovim

augroup myView 
    autocmd!
    autocmd BufWinLeave *.* mkview
    autocmd BufWinEnter *.* silent! loadview
  augroup END
  " the '!' mark helped me get rid of the error on startup
  
" and if you want to be more explicit make custom function
" assuming your error code is E484 eg:
" Error detected while processing BufWinEnter Autocommands for "*":
" E484: Can't open file /home/jan/.local/share/nvim/view/~=+index=
  
 function! LoadView() abort
    try
        loadview
    catch /E484/
        return
    endtry
 endfunction

autocmd BufWinEnter * call LoadView()

Tags:

Misc Example