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.
−
The WideMsg() function below prints a single-line [long] message (of up to (&columns-1) length) without the "Press Enter" prompt, guaranteed:
+
The WideMsg() function below prints a single-line [long] message (of up to (&columns-1) length) without the "Press Enter" prompt, guaranteed:
<pre>
<pre>
−
" WideMsg() prints [long] message up to (&columns-1) length
+
" WideMsg() prints [long] message up to (&columns-1) length
" guaranteed without "Press Enter" prompt.
" guaranteed without "Press Enter" prompt.
function! WideMsg(msg)
function! WideMsg(msg)
−
let x=&ruler | let y=&showcmd
+
let x=&ruler | let y=&showcmd
set noruler noshowcmd
set noruler noshowcmd
redraw
redraw
echo a:msg
echo a:msg
−
let &ruler=x | let &showcmd=y
+
let &ruler=x | let &showcmd=y
endfun
endfun
" To test.
" To test.
:set ruler showcmd
:set ruler showcmd
−
:call WideMsg(repeat('x',&co-1))
+
:call WideMsg(repeat('x',&co-1))
</pre>
</pre>
Line 41:
Line 41:
==Comments==
==Comments==
−
−
----
Latest revision as of 00:11, September 30, 2008
Please review this tip:
This tip was imported from vim.org and needs general review.
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.