Vim: Status line accounts for active window
This commit is contained in:
parent
b8d5228567
commit
926603da2a
1 changed files with 37 additions and 11 deletions
48
vim/vimrc
48
vim/vimrc
|
@ -22,6 +22,7 @@ set autoindent " Enable auto-indentation
|
||||||
set expandtab " Spaces for tab
|
set expandtab " Spaces for tab
|
||||||
set shiftwidth=4 " Spaces per shift
|
set shiftwidth=4 " Spaces per shift
|
||||||
set softtabstop=4 " Spaces to use when editing
|
set softtabstop=4 " Spaces to use when editing
|
||||||
|
set listchars=tab:>-,trail:· " Show me tabs and spaces
|
||||||
|
|
||||||
set number " Enable line numbers
|
set number " Enable line numbers
|
||||||
set wrap " Wrap text
|
set wrap " Wrap text
|
||||||
|
@ -84,17 +85,42 @@ endif
|
||||||
" Status Line
|
" Status Line
|
||||||
" ==============================================================================
|
" ==============================================================================
|
||||||
set laststatus=2 " Enable the statusline
|
set laststatus=2 " Enable the statusline
|
||||||
set statusline= " Initialize it
|
set statusline=%!ActiveStatus() " Style it
|
||||||
set statusline+=%3*%m " Modified flag
|
|
||||||
set statusline+=%6*%{expand('%:p:h')}/ " Full-path to current buffer
|
function! ActiveStatus() abort " When in the active window
|
||||||
set statusline+=%4*%t " File name
|
let statusline="" " Initialize it
|
||||||
set statusline+=%5*%{GitBranch()} " Show Git branch, if applicable
|
let statusline.="%3*%m" " Modified flag
|
||||||
set statusline+=%= " Switch to right-side
|
let statusline.="%6*%{expand('%:p:h')}/" " Full-path to current buffer
|
||||||
set statusline+=%4*%y\ " Filetype
|
let statusline.="%4*%t" " File name
|
||||||
set statusline+=%3* " Color change (see :hi)
|
let statusline.="%5*%{GitBranch()}" " Show Git branch, if applicable
|
||||||
set statusline+=\|%4l\:%2c\| " Line and column
|
let statusline.="%=" " Switch to right-side
|
||||||
set statusline+=%2*%{&spell?'[SPELL]':''} " Spell flag
|
let statusline.="%4*%y\ " " Filetype
|
||||||
set statusline+=%1*%r%0* " Read-only flag
|
let statusline.="%3*" " Color change (see :hi)
|
||||||
|
let statusline.="\|%4l\:%2c\|" " Line and column
|
||||||
|
let statusline.="%2*%{&spell?'[SPELL]':''}" " Spell flag
|
||||||
|
let statusline.="%1*%r%0*" " Read-only flag
|
||||||
|
return statusline
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! PassiveStatus() abort " When in a non-active window
|
||||||
|
let statusline="" " Initialize it
|
||||||
|
let statusline.="%6*%m" " Modified flag
|
||||||
|
let statusline.="%{expand('%:p:h')}/" " Full-path to current buffer
|
||||||
|
let statusline.="%t" " File name
|
||||||
|
let statusline.="%{GitBranch()}" " Show Git branch, if applicable
|
||||||
|
let statusline.="%=" " Switch to right-side
|
||||||
|
let statusline.="%y\ " " Filetype
|
||||||
|
let statusline.="\|%4l\:%2c\|" " Line and column
|
||||||
|
let statusline.="%{&spell?'[SPELL]':''}" " Spell flag
|
||||||
|
let statusline.="%r%0*" " Read-only flag
|
||||||
|
return statusline
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
augroup user_statusline " Change based on active window
|
||||||
|
autocmd!
|
||||||
|
autocmd WinEnter * setlocal statusline=%!ActiveStatus()
|
||||||
|
autocmd WinLeave * setlocal statusline=%!PassiveStatus()
|
||||||
|
augroup END
|
||||||
" ==============================================================================
|
" ==============================================================================
|
||||||
" Mappings
|
" Mappings
|
||||||
" ==============================================================================
|
" ==============================================================================
|
||||||
|
|
Loading…
Reference in a new issue