One possible solution which was not mentioned yet is to go one level above and implement project-specific shell scripts to fire up your vim environment.
This allows vim-specific settings to be passed using the -S
command-line option. The advantage is that it also allows configuring other aspects of the environment, such as the terminal or cscope settings.
For example, let's say I have a C++ project called foo
, for which I want to load vim settings of the file ~/.vim/projects/foo.vim
. I also want to set up a cscope index and launch a terminal window if the command is invoked from some quick launch tool or desktop shortcut. To open up my environment, I have the following script, called vim-foo
:
#!/bin/bash
# Script to setup the VIM development environment of my "foo" project
# Includes building ctags and cscope databases.
VIM_CONFIG=$HOME/.vim/projects/foo.vim
BASE_DIR=$HOME/work/foo
function setup_cscope()
{
CSCOPE_FILES=$BASE_DIR/cscope.files
created_files=false
# check if global cscope.files exist
if [ ! -f $CSCOPE_FILES ]; then
echo "Creating cscope.files"
find $BASE_DIR/src -name '*.cpp' -o -name '*.h' >> $CSCOPE_FILES
created_files=true
fi
# create cscope database
if [ $created_files ] || \
[ ! -f $BASE_DIR/cscope.in.out ] || \
[ ! -f $BASE_DIR/cscope.po.out ] || \
[ ! -f $BASE_DIR/cscope.out ]; then
echo "Creating cscope database"
cscope -b -q -i $CSCOPE_FILES
for f in in.out po.out out; do
mv cscope.$f $BASE_DIR/
done
fi
export CSCOPE_DB=$BASE_DIR/cscope.out
}
# setup everything and finally launch vim
setup_cscope
cd $BASE_DIR
if [[ $TERM == "rxvt-unicode" ]]; then
vim -S $VIM_CONFIG
else
urxvt -e vim -S $VIM_CONFIG
fi
http://stackoverflow.com/questions/1889602/multiple-vim-configurations – Ciro Santilli 新疆改造中心法轮功六四事件 – 2015-07-19T11:54:41.503