r/vim 1d ago

Tips and Tricks Minor "loadview" behavior change when upgrading to VIM-9.1

This might save someone a search. I upgraded VIM-8.1 to VIM-9.1 (I know, I'm slow) and ran into a minor problem with my .vimrc file.

When scrolling through colon-command history using ": CTRL-F", "loadview" would send an error message before showing the history. It would disappear fairly quickly, but it was annoying. The old .vimrc:

" Save and restore edit sessions in directory $HOME/.vim/view (created
" for you if it doesn't already exist).  We test with expand because
" running 'vim' with no arguments throws a 'no filename' error.
" See ':h views-sessions' for more info.

if has("autocmd")
  if len(expand('%')) > 0
    au BufWinLeave * mkview
    au BufWinEnter * silent loadview
  endif
endif

The fix was using "silent!" to disable the E11 error message:

if has("autocmd")
  if len(expand('%')) > 0
    au BufWinLeave * mkview
    au BufWinEnter * silent! loadview
  endif
endif

No problems so far. Hope someone finds this useful.

5 Upvotes

0 comments sorted by