Vim always use global 'statusline' for a freshly opened window. Can this be overruled?

View: New views
3 Messages — Rating Filter:   Alert me  

Vim always use global 'statusline' for a freshly opened window. Can this be overruled?

by Jacky Liu :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hi all :)

I want to use different statusline for the current window so I put
these into my .gvimrc file:

        " Use different statusline for the active window
        autocmd! WinEnter * setlocal statusline=%!MyStatusLine() | echomsg
'xyz'
        autocmd! TabEnter * setlocal statusline=%!MyStatusLine() | echomsg
'xyz'

        " restore the global statusline so that 'StatusLineNC' hi group can
be used
        " for non-active windows
        autocmd! WinLeave * setlocal statusline<

        function! MyStatusLine(...)
                " ... parse statusline otherwise
        endfunction

The 'echomsg' command is just a verification that the autocmd was
successfully fired. But even it does the local statusline still won't
change for a freshly opened window. It was like:
        :vsplit another_file or
        :tabedit another_file
then I got 'xyz' in the message list, but ':echo &l:statusline' still
shows nothing and the statusline was in no way updated. How can I
change this?

Thanks in advance.
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---


Re: Vim always use global 'statusline' for a freshly opened window. Can this be overruled?

by KKde :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


statusline option can be different for different windows.
I believe you have done something wrong

>autocmd! WinLeave *     setlocal statusline<
btw..to restore string options you need to do setlocal statusline=


> then I got 'xyz' in the message list, but ':echo &l:statusline' still
> shows nothing and the statusline was in no way updated. How can I
> change this?

isn' t this ':echo &l:statusline' throwing error?

Regards,
Sarath
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---


Re: Vim always use global 'statusline' for a freshly opened window. Can this be overruled?

by Jacky Liu :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hi, thanks for the reply

> statusline option can be different for different windows.

True. I mean, problem occurs only once when a new window got created.
After that if I switch to another window and switch back, the
statusline would be updated and everything looks normal.

> btw..to restore string options you need to do setlocal statusline=

I suppose 'setlocal statusline<' works too. Anyway the problem's not
here, the 'WinLeave' autocommand works fine as expected as it restores
the global value of 'statusline' when leaving a window and the
'StatusLineNC' coloring would be used for the whole statusline of the
window leaved.

>
> isn' t this ':echo &l:statusline' throwing error?
>

No, my Gvim seems to be OK with it. Does your Vim throw errors? It
does the same thing with 'setlocal statusline?' I suppose.

Anyway, I found Vim to be obstinate with statuslines, it decides when
to refresh them by itself, leaveing the user very few option about it.
What confuse me most here is that the 'echomsg' command got executed
but not the 'setlocal' command preceding it, like it was totally
"optimized away". Another thing I've noticed about statusline is that
there's simply no way to refresh it without destroying an on-showing
pop-up menu, not even the standard statusline-refreshing process 'let
&ro=&ro' given by the Vim help doc. It's not a big problem though,
just would like to know the answer, if there is one.

Thanks again.

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---