我已经在vim中设置了一个非常好的永久状态行,在我的.vimrc
中使用以下配置
" Status line config
set statusline=
set statusline+=%<\ " cut at start
set statusline+=%2*[%n%H%M%R%W]%*\ " flags and buf no
set statusline+=%-40f\ " path
set statusline+=%=%1*%y%*%*\ " file type
set statusline+=%10((%l,%c)%)\ " line and column
set statusline+=%P " percentage of file
现在,由于我经常从测试环境切换到生产环境,我希望vim在状态行中显示由ISPconfig设置的当前用户。
将一个用户(生产服务器)设置为红色的能力将是一个很大的优势:D
好的,我花了一些时间学习vimscript,因为它非常值得:)
因此,如果用户具有值“prod”,则在.vimrc
中添加相关部分以便在状态行中打印$USER
变量并将其着色为红色(使用错误系统颜色)。
"" Functions
function! Prodcolor()
if $USER == "prod"
set statusline+=%#error#
endif
endfunction
" Status line config
set statusline=
call Prodcolor() " Give the error color if `$USER` is "prod"
set statusline+=%{$USER} " Paste the current vim user
set statusline+=%* " Revert color to normal
要在当前的vim会话中立即应用它,请使用vim类型:so .vimrc