0

After saving file in vim the current line is echoed shortly, after which file name and 'written' message is echoed. This is ok and I suppose it is a normal vim behavior, but after a while working on more files, some files echo the current line multiple times (up to 6 times on some occasions as seen on screenshot). As this output is bigger then command line height it triggers a prompt "Press ENTER or command to continue".

vim command line after save

  1. How can I find out why is the echo of current line multiplied for some files?
  2. If the echoing of current line after save isn't normal for vim, is it possible to reasonably find out what is echoing the current line (I have fair amount of plugins and config and I would like to avoid disabling each in turn to find out which is making this mess).
  3. If the echo is done by vim, is it possible to disable it altogether?
aocenas
  • 121
  • 2
  • 8
  • by saving (:w) vim won't echo "current" line. it will report in short how many chars were written into which file, for example in your screenshot, the filename `app.js` has 58 lines, and 1622 chars. try starting your vim by `vim -u NONE`, see if the problem is still there. – Kent May 07 '14 at 12:39

3 Answers3

3

Diagnosis

That's no default Vim behavior. Only the filename, 3L 42C written message comes from :write.

Because the echoed line contains the line number and highlighting, it looks as if it's generated by the :print or :number commands.

The fact that the number of instances increases hints that this is caused by some :autocmd that gets re-defined (without properly clearing the former definition).

Troubleshooting tips

Often, a binary search where you disable half of your (filetype-) plugins, then only one half of that (when the problem is still there), or the other half (when the problem vanished) lets you get to the problematic script quickly. The same can be done with the configuration in your ~/.vimrc (by commenting out blocks).

Also, you can capture a full log of a Vim session with vim -V20vimlog. After quitting Vim, examine the vimlog log file for suspect commands, in your case :print, :number, or :echo[msg].

Ingo Karkat
  • 167,457
  • 16
  • 250
  • 324
1

No, Vim doesn't echo the current line when writing a buffer to disk. It's probably a command/function bound to some event by an autocommand.

  1. Look for possible autocommands:

    :verbose autocmd bufwrite,bufwritepre,bufwritepost,bufwritecmd
    :verbose autocmd filewritepre,filewritepost,filewritecmd
    :verbose autocmd fileappendpre,fileappendpost,fileappendcmd
    :verbose autocmd filterwritepre,filterwritepost
    
  2. Look for possible mappings:

    :verbose map :w
    and so on…
    

Also, do you use syntastic?

romainl
  • 186,200
  • 21
  • 280
  • 313
0

This started happening to me recently, though the current line was only echoed/printed once per write rather than up to 6 times.

By binary search on my plugins and vimrc, as Ingo Karkat suggested in his answer, I narrowed it down to the combination of:

  • a plugin doing what amounted to: autocmd BufWritePre * noautocmd | ...
  • my 'shortmess' neither containing o nor O.

I don't know why this combination causes the current line to be echoed/printed. But it's an incorrect use of the noautocmd command modifier; it should be noautocmd ... not noautocmd | ....

Andy Stewart
  • 5,013
  • 2
  • 28
  • 38