My ~/.vimrc
uses the following statusline setting
set statusline=%F%m%r%h%w\ %{&ff}\ %Y\ [0x\%02.2B]\ %l/%L,%v\ %p%%
Everything is left aligned. help 'statusline'
says that the -
character is used to "Left justify the item. The default is right justified when minwid is larger than the length of the item."
However, I haven't been able to use (or not use) -
to ever align things to the right.
What is an example of having one group of items left aligned and one group right aligned?
I've also tried to use =
but it just prints the =
sign.
vimrc ( :w | so % ), and the terminal mode status line should have the same colors as your color scheme: Above, hi is a shorthand for highlight , which is used to define highlight group colors.
What is a statusline in Vim? The statusline in Vim is the bar along the bottom of the Vim window. By default it does not show when you open Vim until there is more than one window.
You need to prefix the =
with a percent sign: %=
.
Using your example:
set statusline=%F%m%r%h%w\ %{&ff}\ %Y\ [0x\%02.2B]\ %=l/%L,%v\ %p%%
Will right-align the "%l/%L,%v\ %p%%
" group. You should also probably force a truncation using %<
in a suitable place to accommodate narrow windows:
set statusline=%F%m%r%h%w%<\ %{&ff}\ %Y\ [0x\%02.2B]\ %=l/%L,%v\ %p%%
You must use %=
What is at the left of %=
will be left aligned, and what is at the right of %=
will be right aligned.
For example, here is the statusline I use.
set statusline=%f%m%r%h\ [%L]\ [%{&ff}]\ %y%=[%p%%]\ [line:%05l,col:%02v]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With