Search code examples
vimstatusbarauto-indent

Vim, see autoindent state in statusbar


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.


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.