FrozenHeart
FrozenHeart

Reputation: 20756

Can I somehow add my own info to the status line via vimscript

Can I somehow add my own info to the status line via vimscript? I need to create plugin that will update some value in the status line after certain time.

Thanks in advance.

Upvotes: 1

Views: 341

Answers (2)

Ingo Karkat
Ingo Karkat

Reputation: 172648

The 'statusline' option configures what is shown in the status line. You can add the value of arbitrary Vimscript expressions via the %{expr} syntax, e.g.:

:set statusline+=\ %{localtime()}

Note that this gets invoked frequently, so it shouldn't do much processing. Alternatively, just insert a (buffer-local) variable, and use other means (:autocmd) to update the variable value when necessary.

If you plan to make this plugin reusable, better not directly mess with the 'statusline' option, but just offer a (global or autoload) function and instructions for users to include this in their personal option value.

Upvotes: 1

Kent
Kent

Reputation: 195179

yes you can update the value of &statusline, by putting your new stuff in.

e.g.

let &statusline .= "Hello"

this will add a Hello to the end of statusline.

Upvotes: 1

Related Questions