1

So, when I open multiple files, but don't visit the all of them (or the last one), and I try to :quit neovim yells at me that I have to edit those files. No I don't! Stop giving me this error : )

It seems totally strange that it gives me an error for unVISITED files. The fix I've used until now was this:

" Avoid E173 (n more file(s) to edit)
if argc() > 1
 silent blast " load last buffer
 silent bfirst " switch back to the first
endif

But that leads to the following... Any ideas for how to overcome both of these issues?

When opening multiple files, I don't see syntax highlighting for the first file, whereas when I open one file at a time I do.

One file:

Screenshot from 2020-05-08 13-59-50

Screenshot from 2020-05-08 13-59-26

Two files:

Screenshot from 2020-05-08 13-59-43

Screenshot from 2020-05-08 13-58-55

Side note: I alias vi to nvim.

  • 1
    Well, if you remove that block, does it start working again? Also check output of :set ft? to see if it's empty on the first file. You could try to move that block above filetype plugin indent on in your vimrc to see if that helps. But overall, switching buffers in your vimrc tends to create undesirable side effects such as the one you reported. It might also break vim -o or vim -p, etc. – filbranden May 9 at 13:14
  • 1
    Yeup, removing it fixed the syntax issue, but now I'm stuck with the old problems of getting a warning for unVISITED buffers. It's not like I have unsaved changes. I just didn't visit one of the buffers. How do I solve that? Editing Question. – Costa May 9 at 13:18
2

I guess you have your code before filetype on (including runtime defaults.vim or anything else switching filetype on). But it must be placed after it.

Also, my personal advice is to set confirm and get rid of this stuff completely. Or use ZQ, or :q! and such.

UPD. As it turned out, the problem was due to using autocommands with mkview and loadview.

| improve this answer | |
  • 1
    @Costa Just filetype plugin indent on is enough. And it should really be on top of vimrc. – Matt May 9 at 16:33
  • 2
    @Costa Your problem is due to bloody mkview / loadview. Delete this bs and forget it for good. – Matt May 9 at 18:54
  • 1
    I don't think set confirm prevents E173 – Mass May 9 at 23:30
  • 1
    @filbranden It sucks anyway. For example, I never could figure out how to loadview N with splits. It's just simplier zM / zR / za etc. – Matt May 10 at 5:50
  • 1
    @Mass It triggers "yes/no" dialog instead of throwing an error. – Matt May 10 at 5:51
2

Option 1: Use :qa, :q!, or ZQ to quit. Then vim does not prompt for multiple files. On the other hand, it will also not alert for changes made to the current buffer.

Option 2: Always open multiple buffers in spits, or in tab pages. Change your bash alias to

alias vim='nvim -o'

or (for tab pages)

alias vim='nvim -p'

This doesn't solve the problem of using :q twice, but it makes it more visible.

Option 3: Use a combination of +only and -o:

alias vim='nvim +only -o'

The idea here is to open all files in windows, but then only keep one of them.

Option 4: Overwrite arguments on startup.

vim +args\ % file1 file2

or in vimrc,

au VimEnter * args %

vim uses the argument list, or the files you mention in command to determine whether to remind you there are still files to edit. If we manually change that, it will stop alerting you. Of course, you cannot use :n and :prev then.

| improve this answer | |
  • Won't option 3 break using :n to go to file2 though? – filbranden May 9 at 13:38
  • Hm... but will it not alert for changes made? – Costa May 9 at 13:38
  • 1
    @filbranden good point. Added another option which may be better in OPs case. – Mass May 9 at 13:44
  • 1
    @Costa that is odd. I feel like something else is wrong then. – Mass May 9 at 14:32
  • 1
    On the other hand, it will also not alert for changes made. This isn’t really true. :q! won’t alert you for changes in your current buffer, but it will still alert you to changes in other buffers, and :qall will alert you to changes in any of your buffers. – Rich May 9 at 19:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.