4

If I use gvim *.c in a directory with multiple C files, gvim opens the next one once I close the one I am looking at.

The warning message given is E173: n more files to edit.

How do I quit all subsequent files? Meaning I don't want gvim to open any more files.

4

When I tried the same thing, I got this error message:

E173: 3 more files to edit

I ran :help E173 and read

                        *E173*  >
 {number} more files to edit

You are trying to exit, while the last item in the argument list has not been
edited.  This protects you from accidentally exiting when you still have more
files to work on.  See |argument-list|.  If you do want to exit, just do it
again and it will work.

The command :q! worked for me. So did running :q twice (like the help page indicated).

  • 4
    :qa should also work; the difference being that :q! will also quit on various other error conditions (like the buffer not being written), whereas :qa won't. – Martin Tournoij May 26 '17 at 1:25
0

This error occurs because the subsequent files were opened without having been actually loaded: In other words, you never switched to that buffer. So, a way of fixing this would be to cycle through all your files right as you open vim. Adding this to your .vimrc should work:

" do one full loop through each file given through the commandline
if argc() > 1
    for _ in range(argc() - 1)
      next
    endfor
    first
endif
  • 1
    Might be worth using argc() as the count and :next to iterate the arglist instead, since that's what inspires the error. Also, you could rewind things by finishing with :rewind (also :first) so that we still start with the first file. Note that this in general could heavily impact startup time. If using args: could also do for _ in range(argc()-1) | next | endfor | first, and ofc argc()-1 == len(argv())-1 – D. Ben Knoble Jan 26 at 17:51
  • @D.BenKnoble I have fixed the loop to reflect your recommendations. – alehresmann Jan 27 at 18:57

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.