3

I open vim with three files: vim a.txt b.txt c.txt. Then:

  1. edit a.txt, save it by :w, switch to b.txt by :n.
  2. edit b.txt, save it by :w, switch to c.txt by :n.
  3. edit c.txt, save it by :w, and quit vim session by :q.

After I quit, terminal showed a message of "3 files to edit". My question is: What's wrong with my editing process? How to turn off this annoying message?

6

What's wrong with my editing process?

Nothing. Vim likes to talk and, in fact, that message is written before you actually start editing your files, as can be confirmed if you issue gvim instead of vim.

Another clear, unambiguous way to confirm it:

strace -o vimStrace vim a.txt b.txt c.txt

Do what you want with Vim and then close it. Now have a look at the trace file. The first write call is (the English version of)

write(1, "3 Dateien zum Editieren\n", 24) = 24

How to turn off this annoying message?

If your Vim version is recent enough, invoking it with --not-a-term should solve it, as statox already mentioned.

In my system, although --not-a-term is available, it still does not implement that functionality:

--not-a-term    Tells Vim that the user knows that the input and/or output is
        not connected to a terminal.  This will avoid the warning and
        the two second delay that would happen.
        Also avoids the "Reading from stdin..." message.
        {not in Vi}

And as the syscall shows, the message is written to file descriptor 1, i.e. stdout. Since stdout is also used to edit the files, the only reasonable ways to suppress the message would be to turn to Gvim,

gvim a.txt b.txt c.txt > /dev/null

or explore the client-server capability of Vim. Both look overkill.

| improve this answer | |
4

I wouldn't say that there is anything wrong with your editing process I think it's just vim normal behavior.

For what I can say it comes from these lines:

// This message comes before term inits, but after setting "silent_mode"
// when the input is not a tty. Omit the message with --not-a-term.
if (GARGCOUNT > 1 && !silent_mode && !is_not_a_term())
    printf(_("%d files to edit\n"), GARGCOUNT);

So using vim --not-a-term should fix that, here is what the doc says :h --not-a-term:

                            *--not-a-term*
--not-a-term    Tells Vim that the user knows that the input and/or output is
        not connected to a terminal.  This will avoid the warning and
        the two second delay that would happen.
        Also avoids the "Reading from stdin..." message.
        Also avoids the "N files to edit" message.
| improve this answer | |
  • @D.BenKnoble Isn't that the expected behavior? I have the same message when I use Vim and I don't have other $TERM related issues – statox Jul 29 at 15:13
  • 1
    Ah yes you’re right for some reason i thought the message went away /facepalm – D. Ben Knoble Jul 29 at 15:17
  • I'm, like, freaking out man. If you had told me that "X files to edit" always shows up after you exit Vim I would have called you a dirty liar. How could I never have noticed this before? (Probably because it doesn't always show up. ;) I see it in Cygwin but not Ubuntu in WSL...the only platforms available to me at this moment. I'm still kinda freaking out, though, that I hardly noticed how prevalent it is in Cygwin. And why Cyg but not Ubuntu/WSL? Must investigate.) – B Layer Aug 10 at 0:00

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.