6

When using gVim (on Windows; see below) to diff two files which both have very long paths relative to the current working directory, the dreaded "press enter" prompt appears during load, before rendering any of the useful diff information. "Very long paths" here are basically those that are long enough that both of them joined together are longer than whatever columns is set to in my .gvimrc.

This is extremely annoying.

How can I prevent this prompt from appearing in diff mode?

  • I am aware of shortmess and currently have it set to asI. t and T do not seem to have any appreciable effect.
  • I would prefer a solution that did not involve setting cmdheight to some arbitrary large value, because that wastes precious vertical screen space.
  • In my case, gVim is being invoked by an external program (Perforce), so I do not have control over the working directory I'm in before launching vim (it wouldn't matter anyhow, as one of the paths is always long and absolute); nor do I have any real control over ridiculous length of the paths.
  • I do have control over the arguments passed as part of the diff operation.

A gvim invocation that reproduces the issue:

gvim -u NONE -d C:\this\folder_creates_a_very_long\path_which_reproduces_the_problem\for_people_on_stackexchange\to_look_at\a.txt C:\that\folder_creates_a_very_long\path_which_reproduces_the_problem\for_people_on_stackexchange\to_look_at\a.txt

It causes vim to print the message:

"C:\this\folder_creates_a_very_long\path_which_reproduces_the_problem\for_people_on_stackexchange\to_look_at\a.txt" 1L, 3C
"C:\this\folder_creates_a_very_long\path_which_reproduces_the_problem\for_people_on_stackexchange\to_look_at\a.txt" 1L, 3C
  • Could you provide an example on how to reproduce this? Because I don't quite follow what the problem is. I've never noticed this prompt, and I can't get it to appear even with very long paths... – Martin Tournoij Feb 13 '15 at 19:57
  • Done; the "press enter" (:help press-enter) prompt shows up when vim is about to redraw the screen after printing stuff for you to read that didn't all fit on the screen; it "helpfully" doesn't want you to miss that information. But in this case, the information is simply telling me "you opened these two files" which I know... because I opened them. – Josh Feb 13 '15 at 20:11
7

This is controlled with the shortmess option; specifically, set shortmess=Ot seems to do the trick for me.

Meaning of the Ot flags:

      O     message for reading a file overwrites any previous message.
            Also for quickfix message (e.g., ":cn").
      t     truncate file message at the start if it is too long to fit
            on the command-line, "<" will appear in the left most column.
            Ignored in Ex mode.

Note that setting compatible should also work, the default for shortmess is filnxtToO when this is enabled, and it's empty when it's disabled.

Also see :help 'shortmess'

  • Yes! The O option, in particular, was never one I tried along with t/T apparently. – Josh Feb 13 '15 at 20:41

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.