12

After switching git branches, any files that existed on my previous branch raise an E211: File "path/to/file.txt" no longer available warning. I already know that and I find it very annoying that I'm warned about it every time I change the tab or pane that I'm focused on. Especially if I need to close 8 panes of files that no longer exist.

Is there any way to disable this warning or make it something that does not require any input to continue?

enter image description here

James Klein
  • 612
  • 4
  • 15
  • 1
    You say that all those warnings are annoying because you know that those files aren't there, but you are trying to open those files anyway. If you know that `path/to/file.txt` doesn't exist, don't switch to it. – romainl Oct 12 '18 at 15:31
  • 5
    I'm not trying to open them, they are already open. This error fires when switching panes to any open file – James Klein Oct 13 '18 at 16:32

1 Answers1

4

You can tweak Vim's default behavior via the :help FileChangedShell event.

This autocommand is triggered for each changed file. [...] If a FileChangedShell autocommand is present the warning message and prompt is not given.

Unfortunately, by defining an :autocmd (e.g. invoking a no-op like an empty :execute), you'll lose all the default functionality, and would have to re-implement parts of it (without the message on deletion) by inspecing v:fcs_reason. If the sledgehammer approach is fine for you, this will do:

:autocmd FileChangedShell * execute

Instead of *, you could enumerate all of your Git working copies, to make this a bit more targeted.

Ingo Karkat
  • 167,457
  • 16
  • 250
  • 324
  • Gotcha, thanks for the suggestion. I'd rather not override and re-implement the defaults so I'll live with it for now – James Klein Oct 13 '18 at 16:34
  • darn, i agree, ill have to live with this issue then for now also. my solution is to just `:qa!` and open vim again – 1ak31sha Apr 13 '20 at 15:20