Vim: setting a different status bar for split windows

When I open 2 files with horizontal splitting, each window has its own status bar.

eg. with the team

vim -o a.txt b.txt 

I will get the status bar as "a.txt" for the first window and "b.txt" for the second window.

I need to call vim from the command line, and I need to put a custom status bar, and I want a different status bar for each window.

FROM

 vim -o -c "set statusline=hello" a.txt b.txt 

I get hello as status for both windows.

What should I do to get β€œhello” as the status bar for the first window and β€œpeace” for the second window; when calling vim from the command line?

This command does not work:

 vim -o -c "set statusline=hello" a.txt -c "set statusline=world" b.txt 

Please, help.

+7
source share
1 answer

You can use the setlocal command:

 vim -o a.txt b.txt -c "setl stl=hello | wincmd j | setl stl=world" 

Type :help 'stl'

 'statusline' 'stl' string (default empty) global or local to window |global-local| 

We can see that: stl is a global or local to window option.
Thus :setl stl=hello sets the status bar, which is local to the current window.

+7
source

All Articles