Question

Is it possible to have the statusbar in Vim display wether autoindent is on or not?

I have been googling for it and read the following in the Vim homepage: http://vimdoc.sourceforge.net/htmldoc/options.html#%27statusline%27
seems like its not possible.

Was it helpful?

Solution

You can use the %{...} to evaluate a custom expression in the status line

set statusline=%{&autoindent?'autoindent':'noautoindent'}

I didn't put spaces in the expression but if you want them you can use \ to escape them like

set statusline=%{&autoindent\ ?\ 'autoindent'\ :\ 'noautoindent'}

However it might be easier to put it in a function and call the function.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top