Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

My statusline looks something like this:

set statusline+=%m
set statusline+=b%n:
" set statusline+=%f
set statusline+=%F
set statusline+=%R
set statusline+=%Y
set statusline+=\ 
set statusline+=[
set statusline+=row\ %l/%L
set statusline+=,\ 
" set statusline+=column\ %c\ (%v)

set statusline+=column\ %v\ (%c)
set statusline+=]

which, on an average day, when there is no clouds, gives something like this:

[-]b3:options.txt,RO,HELP [row 6291/7778, column 42 (29)]

Now, when I go about splitting windows, and opening different files, some of them modified, some of them not, the things in the statusline start to wiggle back and forth, and it annoys me to no end.

I saw in vim's help (:help 'statusline) that one can set a fixed width of some items.

How would you go about fixing the above items in a way, that if one item is missing, or no matter of its width, that it doesn't affect the other ones ? (i.e. so I can always look at a known position and know what is there ... not move my eyes left and right searching for the thing I need).

share|improve this question
1  
Sorry but the Italic made my eyes hurt! –  Ivo Flipse Mar 31 '10 at 20:21
    
how come? maybe we should all drink some beer to adjust our head to the italic ... :) –  akira Apr 1 '10 at 10:27
    
@Ivo Flipse, @akira - I'll never understand the almost compulsive need of people here to make, something that isn't like everything else, just so (although it makes no difference, whatsoever). I don't mind, hell, I don't care even, but it still is interesting from a psychological point of view. –  ldigas Apr 1 '10 at 13:13
    
@Ivo - also, you said "deleted 10 characters in the body" ... I can't see that in the revision. What did you delete ? –  ldigas Apr 1 '10 at 13:14
    
@Idigas: the 10 chars are the * which make it Italic. I'm just compulsive about markup, that's all. No complaints about the question itself –  Ivo Flipse Apr 1 '10 at 13:27

1 Answer 1

up vote 6 down vote accepted

%= allows you to split the left- and right-justification.

I use this in my status line, with my current git branch left-justified, and the file info right-justified. Even if there is no git information available, everything else stays fully to the right.

edit: I should say that I use %= to fix items in this way because I had trouble getting it to work any other way. You can set a minimum width using %-10.f (with 10 the minimum width for some item f).

edit 2: To answer Idigas's comment below. Here is your current status line (reformatted for space):

set statusline=%mb:%n\ %f%R%Y\ [row\ %l/%L,\ column\ %v\ (%c)]

I would change it to:

set statusline=b:%n\ %f%R%Y%=%m[row\ %l/%L,\ column\ %v\ (%c)]

By setting the left/right split with %= and moving the modified %m to after it, the status line positions seem to be fixed.

share|improve this answer
    
Could you provide an example as to fixing the position of the first few fields ? I sometimes have trouble understanding vimscript's syntax, and this is one of those times ;( –  ldigas Mar 31 '10 at 2:01
    
Hi Idigas, i have edited the answer to show a status line setup that seems not to jump around as much. I had no luck with the minimum width modifiers, so I split the status line instead. –  redacted Mar 31 '10 at 9:40
    
yes, I managed to do that myself. Unfortunatelly, the one I gave above is just an example. There are some other fields in it as well, which still move :( But, nevertheless, thanks for the effort (+1 at least). If no one comes up with the answer how to use max/min fields, I'll accept your answer. Least I could do. –  ldigas Mar 31 '10 at 14:03
    
@Idigas - sorry I couldn't help more! I suspect the only way to fully solve this would be to replace the dynamic parts with a function that returned the expected answer or equal length blank string (e.g, [+] or " " depending on whether the file is modified). –  redacted Mar 31 '10 at 14:48

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.