Fandom

Vim Tips Wiki

How to print full screen width messages

Redirected from VimTip1289

1,624pages on
this wiki
Add New Page
Talk0 Share

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

Tip 1289 Printable Monobook Previous Next

created July 25, 2006 · complexity advanced · author Yakov Lerner · version 6.0


Sometimes, a single-line echo causes the "Press Enter" prompt even though the message is considerably shorter than screen width. This is often an inconvenience for script writers.

The WideMsg() function below prints a single-line [long] message (of up to (&columns-1) length) without the "Press Enter" prompt, guaranteed:

" WideMsg() prints [long] message up to (&columns-1) length
" guaranteed without "Press Enter" prompt.
function! WideMsg(msg)
  let x=&ruler | let y=&showcmd
  set noruler noshowcmd
  redraw
  echo a:msg
  let &ruler=x | let &showcmd=y
endfun

" To test.
:set ruler showcmd
:call WideMsg(repeat('x',&co-1))

Explanation

There are two options, 'showcmd' and 'ruler', that force the "Press Enter" prompt after messages that are shorter than screen width. Either of two options, when set, take space on the right of the bottom line.

The WideMsg() function above saves values of these two suspect options, echo the message, then restores the options.

There is no "Press Enter" prompt, and options are properly restored.

CommentsEdit

Also on Fandom

Random Wiki