Tip 1373 Printable Monobook Previous Next
created 2006 · complexity intermediate · author Yakov Lerner · version n/a
Vim has the ability to display long echo-messages such that they are truncated in the middle to fit the line ('...' will appear in the line). But it's tricky to turn this capability on.
To turn this shortening on, you need two steps:
set shortmess+=T " add T flag to 'shortmess' option
:exe "norm :echomsg repeat('a',&co+10)\n" :exe "norm :echomsg LongMessage\n"
Or use the function ShortEcho()
below.
The first step (set shortmess+=T
) is straightforward. You might already have T in the shortmess
option already.
The second step is tricky. :echo
does not shorten long messages. :echomsg
, by itself, does not shorten long messages. Only when :echomsg
is used under :norm
, are long messages truncated. And don't forget trailing \n
when using :exe norm
.
function! ShortEcho(msg) " regular :echomsg is supposed to shorten long messages when shortmess+=T but it does not. " under "norm echomsg", echomsg does shorten long messages. let saved=&shortmess set shortmess+=T exe "norm :echomsg a:msg\n" let &shortmess=saved endfunction