On Wed, Jun 14, 2006 at 05:20:50PM +0800, Edward L. Fox wrote: > Hi VIMmers, > > According to the user manual ":h statusline", we should be able to > evaluate a customized function to generate the statusline text: > > -------------------- 8< -------------------- > When the option starts with "%!" then it is used as an expression, > evaluated and the result is used as the option value. Example: > :set statusline=%!MyStatusLine() > The result can contain %{} items that will be evaluated too. > -------------------- 8< -------------------- > > But... > > -------------------- 8< -------------------- > :function! MyStatusLine() > : return 'test' > :endfunction > :set statusline=%!MyStatusLine() > -------------------- 8< -------------------- > > VIM complains: > > E539: Illegal character <!>: statusline=%!MyStatusLine() > > What seems to be the matter? > > > Regards, > > > Edward L. Fox
Looks like a bug to me. The code to evaluate the "%!" is in there but the option processing rejects the statusline with a bang(!) in it. This is probably not the best patch to the source, but it allows the statusline string to make it through the option check: --- src/option.h.00 2006-04-24 06:20:49.000000000 -0700 +++ src/option.h 2006-06-14 07:46:06.845082413 -0700 @@ -282,7 +282,7 @@ #define STL_HIGHLIGHT '#' /* highlight name */ #define STL_TABPAGENR 'T' /* tab page label nr */ #define STL_TABCLOSENR 'X' /* tab page close nr */ -#define STL_ALL ((char_u *) "fFtcvVlLknoObBrRhHmYyWwMpPaN{#") +#define STL_ALL ((char_u *) "fFtcvVlLknoObBrRhHmYyWwMpPaN{#!") /* flags used for parsed 'wildmode' */ #define WIM_FULL 1 Alternatively, if your status line function is returning a string and not another status line to be evaluated, you could use: :set statusline=%{MyStatusLine()} gm -- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Gregory H. Margo gmargo at yahoo/com, gmail/com, pacbell/net; greg at margofamily/org