Estou em um sistema RHEL 8.3. Descobri que o built-in vim
e vi
são todos vim
. Eles têm a mesma versão, mas compilados de forma diferente. Segue abaixo meu teste:
[root@192 ~]# which vim
/usr/bin/vim
[root@192 ~]# which vi
/usr/bin/vi
[root@192 ~]# ls -lah `which vim`
-rwxr-xr-x. 1 root root 3.0M Jun 3 2020 /usr/bin/vim
[root@192 ~]# ls -lah `which vi`
-rwxr-xr-x. 1 root root 1.2M Jun 3 2020 /usr/bin/vi
[root@192 ~]# vim --version
VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Jun 3 2020 09:07:54)
Included patches: 1-1763
Modified by <[email protected]>
Compiled by <[email protected]>
Huge version without GUI. Features included (+) or not (-):
+acl +farsi +mouse_sgr -tag_any_white
+arabic +file_in_path -mouse_sysmouse -tcl
+autocmd +find_in_path +mouse_urxvt +termguicolors
-autoservername +float +mouse_xterm +terminal
-balloon_eval +folding +multi_byte +terminfo
+balloon_eval_term -footer +multi_lang +termresponse
-browse +fork() -mzscheme +textobjects
++builtin_terms +gettext +netbeans_intg +timers
+byte_offset -hangul_input +num64 +title
+channel +iconv +packages -toolbar
+cindent +insert_expand +path_extra +user_commands
-clientserver +job +perl/dyn +vertsplit
-clipboard +jumplist +persistent_undo +virtualedit
+cmdline_compl +keymap +postscript +visual
+cmdline_hist +lambda +printer +visualextra
+cmdline_info +langmap +profile +viminfo
+comments +libcall +python/dyn +vreplace
+conceal +linebreak +python3/dyn +wildignore
+cryptv +lispindent +quickfix +wildmenu
+cscope +listcmds +reltime +windows
+cursorbind +localmap +rightleft +writebackup
+cursorshape +lua/dyn +ruby/dyn -X11
+dialog_con +menu +scrollbind -xfontset
+diff +mksession +signs -xim
+digraphs +modify_fname +smartindent -xpm
-dnd +mouse +startuptime -xsmp
-ebcdic -mouseshape +statusline -xterm_clipboard
+emacs_tags +mouse_dec -sun_workshop -xterm_save
+eval +mouse_gpm +syntax
+ex_extra -mouse_jsbterm +tag_binary
+extra_search +mouse_netterm +tag_old_static
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-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/perl5/CORE -lperl -lpthread -lresolv -ldl -lm -lcrypt -lutil -lc
[root@192 ~]# vi --version
VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Jun 3 2020 09:07:06)
Included patches: 1-1763
Modified by <[email protected]>
Compiled by <[email protected]>
Small version without GUI. Features included (+) or not (-):
+acl -extra_search -mouse_netterm -tag_old_static
-arabic -farsi -mouse_sgr -tag_any_white
+autocmd -file_in_path -mouse_sysmouse -tcl
-autoservername -find_in_path -mouse_urxvt -termguicolors
-balloon_eval -float -mouse_xterm -terminal
-balloon_eval_term -folding +multi_byte +terminfo
-browse -footer -multi_lang -termresponse
+builtin_terms +fork() -mzscheme -textobjects
-byte_offset -gettext -netbeans_intg -timers
-channel -hangul_input -num64 -title
-cindent +iconv +packages -toolbar
-clientserver -insert_expand -path_extra -user_commands
-clipboard -job -perl +vertsplit
-cmdline_compl +jumplist -persistent_undo -virtualedit
+cmdline_hist -keymap -printer +visual
-cmdline_info -lambda -profile -visualextra
-comments -langmap -python -viminfo
-conceal -libcall -python3 -vreplace
-cryptv -linebreak -quickfix +wildignore
-cscope -lispindent -reltime -wildmenu
+cursorbind +listcmds -rightleft +windows
-cursorshape -localmap -ruby +writebackup
-dialog -lua +scrollbind -X11
-diff -menu -signs -xfontset
-digraphs -mksession -smartindent -xim
-dnd -modify_fname -startuptime -xpm
-ebcdic -mouse -statusline -xsmp
-emacs_tags -mouse_dec -sun_workshop -xterm_clipboard
-eval -mouse_gpm -syntax -xterm_save
+ex_extra -mouse_jsbterm +tag_binary
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
[root@192 ~]#
Por que eles mantêm duas versões diferentes? É um pouco estranho para mim. Se eles quiserem que vi
os usuários tenham um editor moderno, eles podem simplesmente fazer um link simbólico para vim
. Por curiosidade, abaixo está o resultado em um sistema Ubuntu 20.04. Ambos vi
e vim
apontam para nvim
, o que é razoável.
root@u2004:~# which vi
/usr/bin/vi
root@u2004:~# which vim
/usr/bin/vim
root@u2004:~# ls -la `which vi`
lrwxrwxrwx 1 root root 20 Aug 28 2020 /usr/bin/vi -> /etc/alternatives/vi
root@u2004:~# ls -la `which vim`
lrwxrwxrwx 1 root root 21 Apr 1 08:28 /usr/bin/vim -> /etc/alternatives/vim
root@u2004:~# ls -la /etc/alternatives/vi
lrwxrwxrwx 1 root root 13 Apr 1 08:28 /etc/alternatives/vi -> /usr/bin/nvim
root@u2004:~# ls -la /etc/alternatives/vim
lrwxrwxrwx 1 root root 13 Apr 1 08:28 /etc/alternatives/vim -> /usr/bin/nvim
root@u2004:~# man hier
root@u2004:~# readlink -f `which vi`
/usr/bin/nvim
root@u2004:~# readlink -f `which vim`
/usr/bin/nvim
root@u2004:~#
vi
inicia (uma versão minimalista do) Vim em um modo que é compatível ao máximo com o clássicovi
, empacotado comovim-minimal
. Por outro lado,vim
inicia uma versão mais rica em recursos com configurações padrão mais modernas, empacotadas como arquivosvim-enhanced
.Versões mais antigas do RHEL costumavam não ter o
/etc/alternatives
sistema, então é assim que eles costumavam fazer isso, e o RHEL ainda faz isso por causa da compatibilidade com versões anteriores.