我的centos 7有两个vim二进制文件:
/usr/bin/vi
/usr/bin/vim
当启动其中任何一个时,它们都会显示:
VIM - Vi IMproved
版本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文件。这有可能吗?
发布于 2018-06-27 01:12:47
下面的博客文章讨论了如何为不同的vim版本降级vimrc,这些vim版本可能有不同的包和不同的功能(因此对vimrc的反应也不同):
( max630在对我的问题的评论中提供了答案)
发布于 2018-06-21 00:45:22
您可以将git配置为使用您选择的编辑器。您可以设置环境变量GIT_EDITOR
,也可以使用git config --global core.editor /usr/bin/vim
设置配置文件来设置core.editor
变量。
如果这两项都没有设置,它可能会回退到VISUAL
环境变量。在这一点上,您可能希望在您的~/.bashrc
中将其设置为更具系统范围的解决方案,以便其他可能想要打开编辑器的实用程序默认使用/usr/bin/vi
上的/usr/bin/vim
https://stackoverflow.com/questions/50953126
复制相似问题