I’d like to make my statusline in vim more informative and interesting, and for that I need some ideas. How did you customize your statusline?
7 Answers
Edit:-
Note vim-airline is gaining some traction as the new vimscript option as powerline has gone python.
Seems powerline is where it is at these days:-
Normal status line
Customised status lines for other plugins (e.g. ctrlp)

- 2,080
- 1
- 21
- 17

- 6,833
- 4
- 40
- 44
Here's mine:
set statusline=
set statusline +=%1*\ %n\ %* "buffer number
set statusline +=%5*%{&ff}%* "file format
set statusline +=%3*%y%* "file type
set statusline +=%4*\ %<%F%* "full path
set statusline +=%2*%m%* "modified flag
set statusline +=%1*%=%5l%* "current line
set statusline +=%2*/%L%* "total lines
set statusline +=%1*%4v\ %* "virtual column number
set statusline +=%2*0x%04B\ %* "character under cursor
And here's the colors I used:
hi User1 guifg=#eea040 guibg=#222222
hi User2 guifg=#dd3333 guibg=#222222
hi User3 guifg=#ff66ff guibg=#222222
hi User4 guifg=#a0ee40 guibg=#222222
hi User5 guifg=#eeee40 guibg=#222222

- 3,158
- 24
- 29
-
1c is actually the byte count, even if it is sometimes called column count even in vim help. You can use v to get what is usually meant by column number. – Ludwig Weinzierl Jan 03 '12 at 17:26
-
-
11I love the clarity of the commenting each appended value on it's own line. If I had done that 7 years ago, I wouldn't have thrown it out when I did my last clean OS install. – Bruno Bronosky Mar 20 '13 at 02:32
-
Sweeet! One thing I missing using this is the line that separates the splited session – Julio Marins Nov 15 '16 at 23:32
-
-
I tried putting this after any `colorscheme` was set, but I just see a dual-tone statusline. – trusktr Feb 05 '17 at 06:13
-
1@trusktr Note that `guifg` and `guibg` are for `gvim`. If you are running `vim` in a terminal, try `ctermfg` and `ctermbg` instead. You will also need different colors, the numbers 1-16 or 1-256 depending on how many colors you have enabled in vim. [Corresponding colors](http://vignette3.wikia.nocookie.net/vim/images/1/16/Xterm-color-table.png/revision/latest?cb=20110121055231) for each number. – joelostblom Feb 11 '17 at 12:19
-
where do i put these `hi User1 guifg=#eea040 guibg=#222222 .. etc` ? – alexzander Jun 05 '21 at 12:55
-
@alexzander you may put them in `.gvimrc` or `.vimrc`. If you are going to set `guifg` put them in `.gvimrc` since it only applies in gvim, while `ctermfg` may be put in `.vimrc` – Tassos Jun 06 '21 at 14:01
-
okey so `ctermfg` and `ctermbg` are for `vim-terminal` and in order to apply your colors i must put the color list in `.vimrc`. correct? – alexzander Jun 07 '21 at 08:28
-
@alexzander yes, just replace the `gui` part of my colors with the `cterm` and place them in your .vimrc. You may also set both `gui` and `cterm` variations to your like to have both vim and gvim as you want. – Tassos Jun 07 '21 at 09:00
This is the one I use:
set statusline=
set statusline+=%7*\[%n] "buffernr
set statusline+=%1*\ %<%F\ "File+path
set statusline+=%2*\ %y\ "FileType
set statusline+=%3*\ %{''.(&fenc!=''?&fenc:&enc).''} "Encoding
set statusline+=%3*\ %{(&bomb?\",BOM\":\"\")}\ "Encoding2
set statusline+=%4*\ %{&ff}\ "FileFormat (dos/unix..)
set statusline+=%5*\ %{&spelllang}\%{HighlightSearch()}\ "Spellanguage & Highlight on?
set statusline+=%8*\ %=\ row:%l/%L\ (%03p%%)\ "Rownumber/total (%)
set statusline+=%9*\ col:%03c\ "Colnr
set statusline+=%0*\ \ %m%r%w\ %P\ \ "Modified? Readonly? Top/bot.
Highlight on? function:
function! HighlightSearch()
if &hls
return 'H'
else
return ''
endif
endfunction
Colors (adapted from ligh2011.vim):
hi User1 guifg=#ffdad8 guibg=#880c0e
hi User2 guifg=#000000 guibg=#F4905C
hi User3 guifg=#292b00 guibg=#f4f597
hi User4 guifg=#112605 guibg=#aefe7B
hi User5 guifg=#051d00 guibg=#7dcc7d
hi User7 guifg=#ffffff guibg=#880c0e gui=bold
hi User8 guifg=#ffffff guibg=#5b7fbb
hi User9 guifg=#ffffff guibg=#810085
hi User0 guifg=#ffffff guibg=#094afe

- 7,931
- 11
- 55
- 97
-
2Nice, this avoids the need to have the fancy status line plugins atleast for my use case, eye candy :) – Nishant Jun 29 '16 at 09:48
-
1
-
I tried putting this after any `colorscheme` was set, but I just see a dual-tone statusline. – trusktr Feb 05 '17 at 06:13
-
@trusktr, Not easy to explain....You need the put the first 2 blocks in your vimrc file and the colors block in your current colorscheme file. You can find your current colorscheme file with this command: `:colorscheme` – Reman Feb 05 '17 at 15:54
-
@Reman I can't just stick those colors in my vimrc? I do have other colors in my vimrc that work. – trusktr Feb 06 '17 at 02:53
-
@trusktr, you just have to add above colors at the end of your colorscheme file. – Reman Feb 06 '17 at 11:16
-
@Reman But why is it that I cannot stick these colors in my vimrc after my `colorscheme` command? – trusktr Mar 08 '17 at 19:01
-
-
@trusktr you could use `augroup stl | autocmd ! | autocmd ColorScheme * call LoadStatusLineColors | augroup END` then make a `function LoadStatusLineColors | hi User1 guifg=banana guibg=platypus | hi User2 ... | ... | endfunction` (where `|` is a newline in both snippets. I am assuming that you colorscheme is somehow overridding your statusline `hi`s, so doing what I just showed you will override your colorscheme *every time* it is loaded. :) – dylnmc Oct 23 '17 at 23:46
-
1Your highlight search would be shorter (without any function) just by using ternary operator like this -> `echo &hls ? 'H' : ''` in my case: `let &stl.="%6*%01(%{&hls?'H':''}%)%0* "` – SergioAraujo Feb 21 '18 at 10:35
-
For me, it didn't work because I'm using a terminal, so apparently instead of guifg=hexnumber, I have to set ctermfg and ctermbg and use a named color (Blue, Magenta, Green, etc.) – Mirko Apr 30 '20 at 15:25
What I've found useful is to know which copy/paste buffer (register) is currently active: %{v:register}
. Otherwise, my complete status line looks almost exactly like the standard line.
:set statusline=%<%f\ %h%m%r\ %y%=%{v:register}\ %-14.(%l,%c%V%)\ %P

- 90,870
- 19
- 190
- 224
Some times less is more, do you really need to know the percentage through the file you are when coding? What about the type of file?
set statusline=%F%m%r%h%w\
set statusline+=%{fugitive#statusline()}\
set statusline+=[%{strlen(&fenc)?&fenc:&enc}]
set statusline+=\ [line\ %l\/%L]
set statusline+=%{rvm#statusline()}
I also prefer minimal color as not to distract from the code.
Taken from: https://github.com/krisleech/vimfiles
Note: rvm#statusline
is Ruby specific and fugitive#statusline
is git specific.

- 19,188
- 9
- 91
- 111
I currently use this statusbar settings:
set laststatus=2
set statusline=\ %f%m%r%h%w\ %=%({%{&ff}\|%{(&fenc==\"\"?&enc:&fenc).((exists(\"+bomb\")\ &&\ &bomb)?\",B\":\"\")}%k\|%Y}%)\ %([%l,%v][%p%%]\ %)
My complete .vimrc file: http://gabriev82.altervista.org/projects/vim-configuration/

- 122
- 1
set statusline=%<%f%m\ \[%{&ff}:%{&fenc}:%Y]\ %{getcwd()}\ \ \[%{strftime('%Y/%b/%d\ %a\ %I:%M\ %p')}\]\ %=\ Line:%l\/%L\ Column:%c%V\ %P
This is mine, give as a suggestion

- 1,739
- 1
- 10
- 30