When debugging my vimrc, I often want to log informational messages, e.g. things like "skipping function X because a necessary plugin isn't available". I can use echom statements to do that, but they block. At least, they do under gvim; I get an error window on startup that must be dismissed.

I want a way to log messages for future perusal, without otherwise obstructing what vimrc is doing. Can it be done?

  • Log into a List.
    – dedowsdi
    May 11, 2019 at 3:19

2 Answers 2


As @dedowsdi said in a comment: Log into a list.

The following is derived from stuff I have in one of my plugins:

function! DebugMsg(msg) abort
    if !exists("g:DebugMessages")
        let g:DebugMessages = []
    call add(g:DebugMessages, a:msg)

function! PrintDebugMsgs() abort
  if empty(get(g:, "DebugMessages", []))
    echo "No debug messages."
  for ln in g:DebugMessages
    echo "- " . ln

command DebugStatus call PrintDebugMsgs()

and then use

call DebugMsg("Doing this")
call DebugMsg("Doing")

To display the messages execute the command


I'm sure there are at least a few third party alternatives for this. One I'm familiar with is Decho which is used by netrw. You can enable/disable logging, indicate function enter/leave and depth and other useful things with any one of the following as the message destination:

  • Appended to separate window
  • Uses :echomsg
  • Appended to a variable (default g:dechovar)
  • Appended to a remote server
  • Appended to a tab

The window or tab will be opened automatically by Decho.

A couple other features:

  • Basic output config (e.g. toggle line numbers and/or function names)
  • Basic config of debug message window (e.g. # lines)
  • Option to keep debug window closed until explicitly opened (e.g. to avoid conflicts with plugins that take control of windows).

Get Decho here. And here's the manual

  • Absolutely, @Rich, if that's the case. I know everyone has netrw but all uses of Decho are commented/disabled out of the box. I recall downloading the tarball but that was a while ago so I might be wrong. Do you know definitively that everything needed is in standard Vim install? If not I'll work on confirming it. Thanks!
    – B Layer
    May 11, 2019 at 13:27
  • 1
    @Rich No worries. Cheers.
    – B Layer
    May 13, 2019 at 9:01

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.