1

Is it possible to set color for the warning message "Swap file XXX already exists! ..."? I couldn't figure out which highlight group it belongs to.

1

It is a bit surprising: my first guess was that one of ErrorMsg, Question, or WarningMsg would work. Turns out the highlight group you are looking for is MoreMsg, e.g.: :highlight MoreMsg guifg=red

| improve this answer | |
  • Thanks. I added this line to my .vimrc file and found that it only works when you do :e filename inside vim, where filename is already opened in another vim buffer? If I directly do vi filename from shell, the warning message is still in original color? Can you help me understand this behavior? – Longwu Ou Apr 26 at 13:49
  • My suspicion is when you edit a file from the command line with vim filename, the swap detection occurs before .vimrc is ready so it shows the message with whatever colors are already loaded. You can see it yourself: try to edit a file that has an associated swap with vim filename. When the message appears press o to open it read-only, now execute :e to reload it and you should see the message with the color you specified in your .vimrc. Even if you try the ColorScheme autocommand event you will see the same behavior. That's why I think color schemes are ready before .vimrc – Tae Apr 26 at 14:33

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.