1

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.

FrozenHeart
  • 19,844
  • 33
  • 126
  • 242

2 Answers2

1

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.

Kent
  • 189,393
  • 32
  • 233
  • 301
1

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.

Ingo Karkat
  • 167,457
  • 16
  • 250
  • 324