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, 2020 at 0:59
  • 1
    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" Jun 30, 2020 at 6:28
  • hi @ChristianBrabandt How to revert normal font? Please. I cannot find it in :h echoraw. Maybe :call echoraw("\x1b[41m") | echo " red text" | call echoraw(" \x1b[0m") | echo "unformmated text" isn't the way, is it? Apr 20, 2021 at 12:03
  • echon works weirdly with echoraw() Apr 20, 2021 at 12:14

1 Answer 1


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.

  • Well you may be able to italicize or bold it
    – D. Ben Knoble
    Jun 30, 2020 at 11:52
  • @D.BenKnoble but can we change it from Consolas to Liberation Mono?
    – Maxim Kim
    Jun 30, 2020 at 12:00
  • Doubtful—I think that’s handled by the emulator
    – D. Ben Knoble
    Jun 30, 2020 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, 2020 at 17:54
  • See also defined a simple function that you can call with the warning message as the argument. Summary: function! EchoWarning(msg); echohl WarningMsg; echo "Warning"; echohl None; echon ': ' a:msg; endfunction; call EchoWarning('test') (copy-paste-remove semicolon-indent) Apr 20, 2021 at 11:40

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.