I have a couple of functions chained together to verbose messages in my status line in MacVim. I have noticed that in one particular occasion a line is blank and is not delivering the message it is supposed to deliver:

[24_NOV_2015 13:59:03.544470] <devLogger.LogStreamOut> (DEBUG) Cycle: [0], Retry state for current cycle: [FALSE]
(Blank line)
[24_NOV_2015 13:59:03.554405] <devLogger.LogStreamOut> (DEBUG) Reached last cycle of [0] cycle(s).

However, when I type :messages I can clearly see the missing line:

[24_NOV_2015 13:59:03.544470] <devLogger.LogStreamOut> (DEBUG) Cycle: [0], Retry state for current cycle: [FALSE]
[24_NOV_2015 13:59:03.552491] <devLogger.LogStreamOut> (DEBUG) Success, stream sent to file.
[24_NOV_2015 13:59:03.554405] <devLogger.LogStreamOut> (DEBUG) Reached last cycle of [0] cycle(s).

If I use a blank echom '' at the end of my message functions, all 3 lines come through fine, but I get a blank line at the end of the message stream.

Is there a more elegant way to make sure that every message appears in the status line in Vim?

My core echom wrapper looks like this:

execute 'echohl' error
for l:line in split('My message.', '\\n')
  echomsg l:line
echohl NONE


After further investigation, I now know that the echomsg wrapper that I use to send messages to the messaging facility of vim is not the problem. The problem was a function wrapper that sends the echomsg to a file in parallel. So this is where something goes wrong and my echomsg on the status line is messed up (sometimes).

The function looks like this:

    echon "\r"
    execute 'redir >> ' . l:file
    silent echomsg l:msgString
    silent echo "\n"
    silent! redir END
catch /E190:/
    throw s:myException('Cannot write to file: %s', l:file)

So the right question would probably be: What would be the best way of handling echomsg both on the file out and the message sides.


  • Maybe the "missing" 2nd line is still appended to the 1st, but not visible, at the end (after) the status line. The blank line can suggest a stray \r (<CR>) left at the end of the message. What happens if you change the '\\n' with '\\r' (or even '\\r\\n', try both) in your split() function?
    – VanLaser
    Commented Nov 24, 2015 at 16:14
  • @VanLaser Thanks for the suggestion. It did not work. It might be something far more complicated. The same three functions that are supposed to deliver their three messages just work fine when they are on their own. However, when they are where they are originally (inside a while loop, buried deep inside another function) messages start to be dropped. However, even simple commands such as echom 'See this?' will get dropped at that very same spot. So it must be the while loop?
    – mbilyanov
    Commented Nov 24, 2015 at 18:22

1 Answer 1


I have asked this question in a wrong way. The problem was not related to the echomsg command alone but more about writing the messages to a file. I will be posting a more specific question regarding this issue of: How to append a string to a file in vim script?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.