skip to Main Content

On my Centos 8 machine I have vim and git installed. When I open vim from terminal and view version information I see a slightly different version than when git starts vim e.g. in an interactive rebase process.

The full version info is below but I try to summarize the differences between case 1 and 2:

  • What do I mean with slightly different? Look at line 6, git starts vim Small version while running vim from the terminal starts Huge version
  • bunch of different features of vim are listed

I thought well maybe I have something weird set in my global git config, but running the following yields no output:

$ git config --global core.editor
-- No Output--

$ echo $EDITOR
-- No Output--
$ ls -ls /usr/bin/vim*

Can anybody share some insight about whats going on?

1 When starting vim from Terminal

:version
VIM - Vi IMproved 8.0 (2016 Sep 12, compiled May 11 2019 16:00:09)
Included patches: 1-1763
Modified by <[email protected]>
Compiled by <[email protected]>
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 When Git starts vim

:version
VIM - Vi IMproved 8.0 (2016 Sep 12, compiled May 11 2019 15:59:32)
Included patches: 1-1763
Modified by <[email protected]>
Compiled by <[email protected]>
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 When starting vi from Terminal

:version
VIM - Vi IMproved 8.0 (2016 Sep 12, compiled May 11 2019 16:00:09)
Included patches: 1-1763
Modified by <[email protected]>
Compiled by <[email protected]>
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

2

Answers


  1. There may be multiple versions of Vim on your system. Try update-alternatives --display vim to see if there are others on your system.

    Another command that might help is yum list installed | grep vim to see what yum thinks you have installed.

    Lastly, ls -ls /usr/bin/vim* will list all binaries installed that start with vim. On my system, I have both /usr/bin/vim.tiny and /usr/bin/vim.basic. These are both the same version, but built with slightly different options.

    I think the last one is the difference on your system as well, with you invoking one when you run vim from your shell and git invoking a different one.

    Login or Signup to reply.
  2. When you invoke Git without specifying an editor, the default is vi. On Red Hat and CentOS systems, the vi binary is different from vim and less capable, no matter what Vim versions you have installed. On Debian and Ubuntu systems, they are usually the same binary (via symlinks with the alternatives system) and therefore installing a more capable Vim version affects vi as well.

    If you’re on a Red Hat or CentOS system and you want to use a more capable version of Vim, you should use either vim, vimx, or gvim -f, as appropriate, by setting the VISUAL or EDITOR environment variables or core.editor in the Git configuration settings. If you’re working across systems, you may prefer to set the environment variables in your shell configuration based on what’s available.

    The difference between these is that vim is a console version with no X support, vimx is a console version with X libraries so it supports the clipboard, and gvim is a graphical version. You must use gvim -f in an editor configuration for gvim so that it does not return until you’ve quit; otherwise, it will fork and exit immediately and Git will see no changes to the file.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search