在我的 Centos 8 机器上,我安装了 vim 和 git。当我从终端打开 vim 并查看版本信息时,我看到的版本与 git 启动 vim 时略有不同,例如在交互式rebase
过程中。
完整版本信息如下,但我尝试总结案例 1 和案例 2 之间的差异:
- 我说的略有不同是什么意思?看第 6 行,git 启动 vim
Small version
而从终端运行 vim 开始Huge version
- 列出了 VIM 的一系列不同功能
我想得很好,也许我的全局 git 配置中设置了一些奇怪的东西,但运行以下内容不会产生任何输出:
$ git config --global core.editor
-- No Output--
$ echo $EDITOR
-- No Output--
$ ls -ls /usr/bin/vim*
任何人都可以分享一些关于正在发生的事情的见解吗?
1 从终端启动 vim 时
:version
VIM - Vi IMproved 8.0 (2016 Sep 12, compiled May 11 2019 16:00:09)
Included patches: 1-1763
Modified by <bugzilla@redhat.com>
Compiled by <bugzilla@redhat.com>
Huge version without GUI. Features included (+) or not (-):
+acl -clientserver +dialog_con +find_in_path +keymap +modify_fname +multi_byte +profile +statusline +textobjects +wildignore
+arabic -clipboard +diff +float +lambda +mouse +multi_lang +python/dyn -sun_workshop +timers +wildmenu
+autocmd +cmdline_compl +digraphs +folding +langmap -mouseshape -mzscheme +python3/dyn +syntax +title +windows
-autoservername +cmdline_hist -dnd -footer +libcall +mouse_dec +netbeans_intg +quickfix +tag_binary -toolbar +writebackup
-balloon_eval +cmdline_info -ebcdic +fork() +linebreak +mouse_gpm +num64 +reltime +tag_old_static +user_commands -X11
+balloon_eval_term +comments +emacs_tags +gettext +lispindent -mouse_jsbterm +packages +rightleft -tag_any_white +vertsplit -xfontset
-browse +conceal +eval -hangul_input +listcmds +mouse_netterm +path_extra +ruby/dyn -tcl +virtualedit -xim
++builtin_terms +cryptv +ex_extra +iconv +localmap +mouse_sgr +perl/dyn +scrollbind +termguicolors +visual -xpm
+byte_offset +cscope +extra_search +insert_expand +lua/dyn -mouse_sysmouse +persistent_undo +signs +terminal +visualextra -xsmp
+channel +cursorbind +farsi +job +menu +mouse_urxvt +postscript +smartindent +terminfo +viminfo -xterm_clipboard
+cindent +cursorshape +file_in_path +jumplist +mksession +mouse_xterm +printer +startuptime +termresponse +vreplace -xterm_save
system vimrc file: "/etc/vimrc"
user vimrc file: "$HOME/.vimrc"
2nd user vimrc file: "~/.vim/vimrc"
user exrc file: "$HOME/.exrc"
defaults file: "$VIMRUNTIME/defaults.vim"
fall-back for $VIM: "/etc"
f-b for $VIMRUNTIME: "/usr/share/vim/vim80"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1
-specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/python3.6m -U_FORTIFY_SOURCE -D_FORTIFY_
SOURCE=1
Linking: gcc -L. -Wl,-z,relro -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,--enable-new-dtags -Wl,-z,relro -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-ha
rdened-ld -Wl,-z,relro -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -L/usr/local/lib -Wl,--as-needed -o vim -lm -lselinux -lncurses -lacl -lattr -lgpm -ldl -Wl,--enable-new-dtags -Wl,-z,relro -Wl,-z,now
-specs=/usr/lib/rpm/redhat/redhat-hardened-ld -Wl,-z,relro -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -fstack-protector-strong -L/usr/local/lib -L/usr/lib64/perl5/CORE -lperl -lpthread -lresolv -ldl -lm -lcrypt -
lutil -lc
2 当 Git 启动 vim 时
:version
VIM - Vi IMproved 8.0 (2016 Sep 12, compiled May 11 2019 15:59:32)
Included patches: 1-1763
Modified by <bugzilla@redhat.com>
Compiled by <bugzilla@redhat.com>
Small version without GUI. Features included (+) or not (-):
+acl -cindent +cursorbind -extra_search +iconv +listcmds -mouse_netterm +packages -rightleft -tag_old_static -toolbar +windows
-arabic -clientserver -cursorshape -farsi -insert_expand -localmap -mouse_sgr -path_extra -ruby -tag_any_white -user_commands +writebackup
+autocmd -clipboard -dialog -file_in_path -job -lua -mouse_sysmouse -perl +scrollbind -tcl +vertsplit -X11
-autoservername -cmdline_compl -diff -find_in_path +jumplist -menu -mouse_urxvt -persistent_undo -signs -termguicolors -virtualedit -xfontset
-balloon_eval +cmdline_hist -digraphs -float -keymap -mksession -mouse_xterm -printer -smartindent -terminal +visual -xim
-balloon_eval_term -cmdline_info -dnd -folding -lambda -modify_fname +multi_byte -profile -startuptime +terminfo -visualextra -xpm
-browse -comments -ebcdic -footer -langmap -mouse -multi_lang -python -statusline -termresponse -viminfo -xsmp
+builtin_terms -conceal -emacs_tags +fork() -libcall -mouse_dec -mzscheme -python3 -sun_workshop -textobjects -vreplace -xterm_clipboard
-byte_offset -cryptv -eval -gettext -linebreak -mouse_gpm -netbeans_intg -quickfix -syntax -timers +wildignore -xterm_save
-channel -cscope +ex_extra -hangul_input -lispindent -mouse_jsbterm -num64 -reltime +tag_binary -title -wildmenu
system vimrc file: "/etc/virc"
user vimrc file: "$HOME/.virc"
2nd user vimrc file: "~/.vim/virc"
user exrc file: "$HOME/.exrc"
defaults file: "$VIMRUNTIME/defaults.vim"
fall-back for $VIM: "/etc"
f-b for $VIMRUNTIME: "/usr/share/vim/vim80"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1
-specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/python3.6m -U_FORTIFY_SOURCE -D_FORTIFY_
SOURCE=1
Linking: gcc -Wl,-z,relro -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -L/usr/local/lib -Wl,--as-needed -o vim -lm -lselinux -lncurses -lacl -lattr -ldl
3 从终端启动 vi 时
:version
VIM - Vi IMproved 8.0 (2016 Sep 12, compiled May 11 2019 16:00:09)
Included patches: 1-1763
Modified by <bugzilla@redhat.com>
Compiled by <bugzilla@redhat.com>
Huge version without GUI. Features included (+) or not (-):
+acl -clientserver +dialog_con +find_in_path +keymap +modify_fname +multi_byte +profile +statusline +textobjects +wildignore
+arabic -clipboard +diff +float +lambda +mouse +multi_lang +python/dyn -sun_workshop +timers +wildmenu
+autocmd +cmdline_compl +digraphs +folding +langmap -mouseshape -mzscheme +python3/dyn +syntax +title +windows
-autoservername +cmdline_hist -dnd -footer +libcall +mouse_dec +netbeans_intg +quickfix +tag_binary -toolbar +writebackup
-balloon_eval +cmdline_info -ebcdic +fork() +linebreak +mouse_gpm +num64 +reltime +tag_old_static +user_commands -X11
+balloon_eval_term +comments +emacs_tags +gettext +lispindent -mouse_jsbterm +packages +rightleft -tag_any_white +vertsplit -xfontset
-browse +conceal +eval -hangul_input +listcmds +mouse_netterm +path_extra +ruby/dyn -tcl +virtualedit -xim
++builtin_terms +cryptv +ex_extra +iconv +localmap +mouse_sgr +perl/dyn +scrollbind +termguicolors +visual -xpm
+byte_offset +cscope +extra_search +insert_expand +lua/dyn -mouse_sysmouse +persistent_undo +signs +terminal +visualextra -xsmp
+channel +cursorbind +farsi +job +menu +mouse_urxvt +postscript +smartindent +terminfo +viminfo -xterm_clipboard
+cindent +cursorshape +file_in_path +jumplist +mksession +mouse_xterm +printer +startuptime +termresponse +vreplace -xterm_save
system vimrc file: "/etc/vimrc"
user vimrc file: "$HOME/.vimrc"
2nd user vimrc file: "~/.vim/vimrc"
user exrc file: "$HOME/.exrc"
defaults file: "$VIMRUNTIME/defaults.vim"
fall-back for $VIM: "/etc"
f-b for $VIMRUNTIME: "/usr/share/vim/vim80"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/red
hat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/python
3.6m -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc -L. -Wl,-z,relro -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,--enable-new-dtags -Wl,-z,relro -Wl,-z,now -specs=/usr/lib/rpm
/redhat/redhat-hardened-ld -Wl,-z,relro -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -L/usr/local/lib -Wl,--as-needed -o vim -lm -lselinux -lncurses -lacl -lattr -lgpm -ldl -Wl,--enable
-new-dtags -Wl,-z,relro -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -Wl,-z,relro -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -fstack-protector-strong -L/usr/local/lib -L/usr/lib64/perl
5/CORE -lperl -lpthread -lresolv -ldl -lm -lcrypt -lutil -lc
您的系统上可能有多个版本的 Vim。尝试update-alternatives --display vim
以查看系统上是否有其他系统。
另一个可能有帮助的命令是yum list installed | grep vim
查看 yum 认为您已安装的内容。
最后,ls -ls /usr/bin/vim*
将列出所有安装的以 vim 开头的二进制文件。在我的系统上,我既有/usr/bin/vim.tiny
,也有/usr/bin/vim.basic
。它们都是相同的版本,但构建的选项略有不同。
我认为最后一个也是您系统上的不同之处,当您从 shell 运行vim
时,您会调用一个,而 git 会调用另一个。
当您在不指定编辑器的情况下调用 Git 时,默认值为vi
。 在 Red Hat 和 CentOS 系统上,无论您安装了什么 Vim 版本,vi
二进制文件都不同于vim
二进制文件,并且功能较差。 在 Debian 和 Ubuntu 系统上,它们通常是相同的二进制文件(通过与替代系统的符号链接(,因此安装功能更强大的 Vim 版本也会影响vi
。
如果您使用的是 Red Hat 或 CentOS 系统,并且想要使用功能更强大的 Vim 版本,则应酌情使用vim
、vimx
或gvim -f
,方法是在 Git 配置设置中设置环境变量或core.editor
VISUAL
或EDITOR
。 如果您跨系统工作,您可能更愿意根据可用内容在 shell 配置中设置环境变量。
它们之间的区别在于,vim
是没有 X 支持的控制台版本,vimx
是具有 X 库的控制台版本,因此它支持剪贴板,gvim
是图形版本。 您必须在编辑器配置中使用gvim -f
进行gvim
,以便在您退出之前它不会返回;否则,它将立即分叉并退出,Git 将看不到对文件的更改。