问题
I share my ~/.vimrc file between different computers and use it with three different vims (macvim in mac, gvim in my Ubuntu desktop and plain old vim in the servers which I manage)
Most of what I have in my ~/.vimrc file applies to all three instance, but I want to make some small changes based on which vim I am using (like removing certain plugins when invoked vim from console)
My question is how do I distinguish different vim executables in my ~/.vimrc, so that I can have different settings for different vim's?
回答1:
I, too, use the same config in different environments. This is what I have in my vimrc:
let os = substitute(system('uname'), '\n', '', '')
if has('gui_running')
" generic GUI settings go here
if os == 'Darwin' || os == 'Mac'
" MacVim-specific settings go here
elseif os == 'Linux'
" GVim-specific settings go here
endif
else
" generic CLI Vim settings go here
if os == 'Darwin' || os == 'Mac'
" Mac OS X-specific CLI Vim settings go here
elseif os == 'Linux'
" Linux-specific CLI Vim settings go here
endif
endif
来源:https://stackoverflow.com/questions/17018416/find-out-vim-executable-name-inside-vimrc