2

I would like to change the color of part of the command line, the stuff that's echo'd from vim scripts. I know it can be different since when your search hits the bottom it prints a message in red text.

I tried to echo vt100 color codes but they were escaped instead. For example, :echo "\033[0;32m some text" just prints those characters literally (except the escape, which is shown as ^[)

Ideally I'd like to find a solution that works in both vim-gtk as well as the terminal UI.

  • 1
    Try :help echohl – D. Ben Knoble Jun 30 at 0:59
  • I am pretty sure, you can do this starting from 8.2.258 and using the echoraw() function, like this: call echoraw("\033[38;5;124m")|echo "red text" – Christian Brabandt Jun 30 at 6:28
3

Try combination of :h echohl and :h echon:

:echohl Statement | echon "Hello " | echohl Identifier | echon "World" | echohl None | echon "!!!"

echohl will apply highlight group to the next echo, echon or echomsg, but if you want to apply highlighting to a part of your message you should use echon.

enter image description here

To have all your message in one color, use echo or echomsg:

:echohl Todo | echo "Hello World!!!" | echohl None

enter image description here

To define your own colors use :h :hi

:hi MyColor guifg=#00ff00 ctermfg=green
:echohl MyColor | echo "Hello World!!!" | echohl None

enter image description here

You can not change font of the messages, but I might be wrong.

| improve this answer | |
  • Well you may be able to italicize or bold it – D. Ben Knoble Jun 30 at 11:52
  • @D.BenKnoble but can we change it from Consolas to Liberation Mono? – Maxim Kim Jun 30 at 12:00
  • Doubtful—I think that’s handled by the emulator – D. Ben Knoble Jun 30 at 12:01
  • This is exactly what I was looking for! Thanks! I was trying to Google for an answer for this initially, but searching "vim change command line color" turned up a lot of results about setting syntax highlighting and color schemes instead – Thomas N Jun 30 at 17:54

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.