How can I calculate the width & statusline as shown on the screen?

I am writing a plugin that tries to use extra spaces in the status bar, displaying information of arbitrary length. Depending on the state of the current buffer, I want to display a specific fragment of this information.

  • I can capture the &statusline format &statusline , however this length can be very different from the actual screen length after all processing has been completed.

  • %< , and friends will not help me here, because I may need to trim from both ends of the line if the information I want to see is in the middle. I can determine which section of the string I want using the current status of the active buffer.

Is there any way to capture the processed status line through vimscript so that I can change it and make reasonable decisions based on its length?

+4
source share
1 answer

You should ask your question on the vim mailing list.

If there is a trick to capturing an extended status line, it is more likely that someone will recognize it. (BTW, do not forget that the elements may be justified.)

You may need to play with winwidth() and deploy the official status line yourself to manage your changes.

+4
source

Source: https://habr.com/ru/post/1334539/


All Articles