How to truncate a Vim 'statusline' field from the right?

1k views Asked by At

I'm trying to set the 'statusline' option of a quickfix window like this:

setlocal statusline=%t%.66{'\ '.w:quickfix_title}%=\ %11.(%c,%l/%L\ %P%)

But when the field %.66{'\ '.w:quickfix_title} is longer than 66 characters, its left side is truncated by default. I want it to be right truncated so I can see the beginning of this field.

(I notice that Vim provides %< to also truncate from the left hand. But there's no %> as a counterpart.)

1

There are 1 answers

1
Bohr On BEST ANSWER

I come up with a solution during writing this question:

Just replace %.66{'\ '.w:quickfix_title} with %{strpart('\ '.w:quickfix_title,0,66)}

See h strpart(