简体   繁体   English

安装多个版本的Vim,并分别使用不同的.vimrc文件

[英]Install multiple version of Vim, and make each use different .vimrc file, respectively

Make it on Linux. 在Linux上制作它。 The reason to use more than one version of Vim, is because one version would be heavily hacked, for Lisp jobs. 使用多个Vim版本的原因是因为一个版本会被严重攻击,因为Lisp作业。 I want separate it and make it use it's own .vimrc file as well. 我想分开它并使它使用它自己的.vimrc文件。

/usr/bin/vim   use -> ~/.vimrc
/my/vim        use -> ..../another_vimrc

Command line option 命令行选项

You can give the -u parameter to your command line. 您可以将-u参数提供给命令行。 This parameter will force the vim to read the specific vimrc without reading the system wide configurations: 此参数将强制vim读取特定的vimrc而不读取系统范围的配置:

/my/vim -u /path/another_vimrc

You can even create a command alias, with which you can start this custom vim. 您甚至可以创建命令别名,使用该别名可以启动此自定义vim。 Put this in your .bash_profile for eg: 把它放在.bash_profile ,例如:

alias customvim /my/vim -u /path/another_vimrc

And then start this custom vim with: 然后使用以下命令启动此自定义vim:

customvim

Building configuration 建筑配置

You can specify the prefix option to the configuration script of when you're building from source. 您可以在从源构建时为配置脚本指定prefix选项。 If you set this, vim will look for configuration file in the prefixed directory. 如果设置此项,vim将在前缀目录中查找配置文件。

For eg if you do with stow : 例如,如果您使用stow

./configure --prefix=/usr/local/stow/vim-7.3/ && make install

Then the vim will be installed in /usr/local/stow/vim-7.3/ and the custom configuration should be in /usr/local/stow/vim-7.3/etc/vimrc 然后vim将安装在/usr/local/stow/vim-7.3/ ,自定义配置应该在/usr/local/stow/vim-7.3/etc/vimrc

You can use the Predefined Vim variables(v:version) . 您可以使用Predefined Vim variables(v:version)
Suppose you have installed both vim6 and vim7 , you can create two .vimrc_X files: 假设您已经安装了vim6vim7 ,则可以创建两个.vimrc_X文件:

~/.vimrc_6
~/.vimrc_7

Then you create another .vimrc file: 然后你创建另一个.vimrc文件:

~/.vimrc

which contains: 其中包含:

if v:version >=700
    source ~/.vimrc_7
elseif v:version >=600
    source ~/.vimrc_6
endif

看看Vim filetype插件(搜索ftplugin),它允许您为给定的文件类型指定配置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM