我如何获得 vim 的不同版本以忽略 ~/vimrc 中它们不是插件的部分?

How do I get different builds of vim to ignore parts of the ~/vimrc that they do not the the plugins for?

我的 centos 7 有两个 vim 二进制文件:
/usr/bin/vi
/usr/bin/vi米

启动它们中的任何一个时,它们会弹出:

VIM - Vi IMproved
version 7.4.1099

从网上搜索我认为这两个版本是 vim 和 vim-minimal。问题是 vi 和 vim-minimal 对 ~/.vimrc 的解释不同。打开时 vim 很棒。打开 vim-minimal 时出现很多错误。下面是我的 ~/.vimrc 文件的表示:

set number
set nowrap
set modeline
set clipboard=unnamedplus  "Enables mouse center clip pasting, while holding shift, in insert mode.

"Below sets up the mouse in such a way that allows vi split screen resizing while in tmux and screen.
set mouse+=a
if &term =~ '^screen'
    " tmux knows the extended mouse mode
    set ttymouse=xterm2
endif

""""""""""""""""""""""""""""""""""""""""""""""""
""" User Defined Functions
""""""""""""""""""""""""""""""""""""""""""""""""
"Opens up sage specific work in new tabs
fu! Setup1()
  :bd!|e /home/me/example1.h | vsplit /home/me/example1.cc
  :tabnew /home/me/example2.h | vsplit /home/me/example2.cc
  :tabnew /home/me/example3.h | vsplit /home/me/example3.cc
  :tabnew /home/me/example4.h | vsplit /home/me/example4.cc
  :tabnew /home/me/example5.h | vsplit /home/me/example5.cc
  :tabnew /home/me/example6.h | vsplit /home/me/example6.cc
endfunction

"Opens up the most edited rc files in new tabs
fu! RCS()
  :bd!|e ~/.cshrc
  :tabnew ~/.vimrc
  :tabnew ~/.tmux.conf
endfunction

问题出在我的用户定义函数上。当 /usr/bin/vi 打开时,它会在新选项卡中打开我的两个功能中的所有文档。一个合理的解决方法是不使用 /usr/bin/vi 但这是 git 打开的。

理想情况下,我可以有一个 if 语句来检查 运行 这个 rc 文件的二进制文件是什么。这可能吗?

您可以配置 git 以使用您选择的编辑器。您可以设置环境变量 GIT_EDITOR 或者您可以使用 git config --global core.editor /usr/bin/vim 设置配置文件来设置 core.editor 变量。

如果这些都没有设置,它可能会回退到 VISUAL 环境变量。关于这一点,您可能希望在 ~/.bashrc 中将其设置为更系统范围的解决方案,以便其他可能想要打开编辑器的实用程序默认为 /usr/bin/vim 而不是 /usr/bin/vi

以下博客 post 讨论了如何针对可能具有不同包和不同功能的 vim 的不同构建降级 vimrc(从而对 vim 做出反应rc 不同):

gracefully degrading .vimrc

(max630 在我的问题的评论中提供的答案)