{ NF Evaluate expression between '%{' and '}' and substitute result.
Note that there is no '%' before the closing '}'. The
expression cannot contain a '}' character, call a function to
- work around that. See |stl-%{| below.
+ work around that. See |stl-%{| below. Use '%0{' to insert the
+ result verbatim.
{% - This is almost same as { except the result of the expression is
re-evaluated as a statusline format string. Thus if the
return value of expr contains % items they will get expanded.
A result of all digits is regarded a number for display purposes.
Otherwise the result is taken as flag text and applied to the rules
described above.
+ *stl-%0{*
+ With %0{ neither applies: the result is inserted as a literal string.
Watch out for errors in expressions. They may render Vim unusable!
If you are stuck, hold down ':' or 'Q' to get a prompt, then quit and
status-line windows.txt /*status-line*
statusmsg-variable eval.txt /*statusmsg-variable*
stl-%! options.txt /*stl-%!*
+stl-%0{ options.txt /*stl-%0{*
stl-%@ options.txt /*stl-%@*
stl-%[FuncName] options.txt /*stl-%[FuncName]*
stl-%{ options.txt /*stl-%{*
well.
- New argument handling for user commands |:command-nargs| using the "-nars=_"
attribute to handle completion of single arguments with spaces as expected.
+- Support %0{} in 'statusline' to insert the expression result verbatim and
+ not drop leading spaces |stl-%0{|.
Platform specific ~
-----------------
if (reevaluate)
s++;
- itemisflag = TRUE;
+ // %0{} keeps the result verbatim
+ itemisflag = zeropad ? FALSE : TRUE;
t = p;
while ((*s != '}' || (reevaluate && s[-1] != '%'))
&& *s != NUL && p + 1 < out + outlen)
do_unlet((char_u *)"g:actual_curbuf", TRUE);
do_unlet((char_u *)"g:actual_curwin", TRUE);
- if (str != NULL && *str != NUL)
+ if (!zeropad && str != NULL && *str != NUL)
{
if (*skipdigits(str) == NUL)
{
call assert_match('^vimLineComment\s*$', s:get_statusline())
syntax off
+ " %0{: result of expression is inserted verbatim
+ set statusline=%{'\ x'}
+ call assert_match('^x\s*$', s:get_statusline())
+ set statusline=%0{'\ x'}
+ call assert_match('^ x\s*$', s:get_statusline())
+ set statusline=%{'000'}
+ call assert_match('^0\s*$', s:get_statusline())
+ set statusline=%0{'000'}
+ call assert_match('^000\s*$', s:get_statusline())
+
"%{%expr%}: evaluates expressions present in result of expr
func! Inner_eval()
return '%n some other text'
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 538,
/**/
537,
/**/