O'Reilly logo

Mastering Vim by Ruslan Osipov

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Surfacing output

You can print the content of a variable (or the results of any operation) into a status line using echo:

echo g:animal_name

One thing about echo, though, is that the output does not get logged anywhere and there's no way to view the message once it's dismissed.

For that, there's :echomsg (or :echom for short):

echom g:animal_name . ' is an animal'echom 'here is an another message'

To see the log of messages from this sessions, execute the following command:

:messages

Now, you can see every message we printed:

In fact, many operations log messages via echom. For instance, file write using :w does so:

Messages can be a powerful ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required