I like the default statusline in Vim, but would you like to add the filetype to it.
Is it possible to add the filetype to the default statusline without having to create a new statusline from scratch?
I like the default statusline in Vim, but would you like to add the filetype to it.
Is it possible to add the filetype to the default statusline without having to create a new statusline from scratch?
As you can see with :set statusline?, the default 'statusline' option is empty in vim. You'll need to overwrite it.
Here's the most simple example with filename and filetype:
set statusline=%f%=%{&filetype}
%f : filename%= : separation between left and right%{filetype} : obviously, the file typeSee :h 'statusline' for more examples and other details.
If you want to show the mode you're in, you can write a dictionary to get the string you expect depending on the result of mode().
This is how I set it:
let g:currentmode={
\ '__' : '- ',
\ 'c' : 'C ',
\ 'i' : 'I ',
\ 'ic' : 'I ',
\ 'ix' : 'I ',
\ 'n' : 'N ',
\ 'multi' : 'M ',
\ 'ni' : 'N ',
\ 'no' : 'N ',
\ 'R' : 'R ',
\ 'Rv' : 'R ',
\ 's' : 'S ',
\ 'S' : 'S ',
\ '^S' : 'S ',
\ 't' : 'T ',
\ 'v' : 'V ',
\ 'V' : 'V ',
\ '^V' : 'V ',
\}
Note that ^S and ^V are single characters produced by typing <c-v>X in insert mode (where X is whatever alphabetic character).
Now, g:current_mode[mode()] will give the right-hand side string depending on mode(). Adjust it to your liking, whith the help of :h mode().
Here is the new statusline showing the mode at the beginning (between spaces):
set statusline=\ %{g:curentmode[mode()]}\ %f%=%{&filetype}