Vim Tips Wiki
Register
(Change to TipImported template + severe manual clean)
(Move categories to tip template)
Line 9: Line 9:
 
|version=6.0
 
|version=6.0
 
|rating=12/6
 
|rating=12/6
 
|category1=Scripting
  +
|category2=
 
}}
 
}}
 
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.
 
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.
Line 41: Line 43:
   
 
----
 
----
[[Category:Scripting]]
 

Revision as of 09:25, 25 April 2008

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.

Comments