Estou tentando copiar minha configuração local do vimrc para um novo servidor linux que acabei de configurar:
scp -rp .vim/ nagios:~
scp .vimrc nagios:~
Em seguida, com ls -hoal
na máquina remota no meu diretório ~
:
drwxr-xr-x 4 <me> 51 Jun 29 13:34 .vim
-rw-r--r-- 1 <me> 431 Jul 7 10:59 .vimrc
Quando eu inicio o vim com vi
(já que este é um servidor centos sem um link simbólico para o vim) meu vimrc não carrega.
Eu encontrei esta pergunta do StackOverflow que sugeria algumas coisas, nenhuma das quais funcionou. Por exemplo:
Na resposta aceita posso ver que ele encontra e lê meu arquivo vimrc, para referência este é o meu vimrc:
execute pathogen#infect()
set shiftwidth=2
set softtabstop=2
set tabstop=2
autocmd Filetype yml setlocal ts=2 sw=2 expandtab autoindent
syntax on
filetype plugin indent on
set autoindent
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0
E aqui está o que eu encontro no arquivo strace do vim:
fchdir(3) = 0
chdir("<my home>) = 0
getcwd("<my home>", 4096) = 24
fchdir(3) = 0
close(3) = 0
stat("<my home>/.vimrc", {st_mode=S_IFREG|0644, st_size=431, ...}) = 0
open("<my home>/.vimrc", O_RDONLY) = 3
fcntl(3, F_GETFD) = 0
fcntl(3, F_SETFD, FD_CLOEXEC) = 0
fcntl(3, F_GETFL) = 0x8000 (flags O_RDONLY|O_LARGEFILE)
fstat(3, {st_mode=S_IFREG|0644, st_size=431, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fadbac2e000
read(3, "execute pathogen#infect()\n\nset s"..., 4096) = 431
read(3, "", 4096) = 0
read(3, "", 4096) = 0
close(3) = 0
Então, parece que ele encontra, lê algumas linhas e depois morre.
No entanto, a resposta com mais votos nessa pergunta sugere algumas outras coisas para verificar. Quando executo o :scriptnames
na minha instalação local (funcionando) do vim, vejo:
1: /usr/share/vim/vimrc
2: /usr/share/vim/vim74/debian.vim
3: /usr/share/vim/vim74/syntax/syntax.vim
4: /usr/share/vim/vim74/syntax/synload.vim
5: /usr/share/vim/vim74/syntax/syncolor.vim
6: /usr/share/vim/vim74/filetype.vim
7: ~/.vimrc
8: ~/.vim/autoload/pathogen.vim
E depois algumas outras coisas depois que estão carregando todos os meus outros plugins, bem como algumas coisas em /usr/share/vim
.
A execução de :echo $HOME
e / ou :echo $MYVIMRC
funciona conforme o esperado.
No entanto, quando tento isso na máquina remota, não obtenho nenhuma saída para nenhum dos três comandos acima.
Minha máquina local é o Xubuntu 14.04 com essa saída para vi --version
:
vi --version
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Jan 2 2014 19:39:32)
Included patches: 1-52
Modified by [email protected]
Compiled by buildd@
Huge version without GUI. Features included (+) or not (-):
... bunch of what's enabled ...
system vimrc file: "$VIM/vimrc"
user vimrc file: "$HOME/.vimrc"
2nd user vimrc file: "~/.vim/vimrc"
user exrc file: "$HOME/.exrc"
fall-back for $VIM: "/usr/share/vim"
... compilation options ...
Na máquina remota, estou rodando o centos com a versão exata centos-release-7-2.1511.el7.centos.2.10.x86_64
e versão vim:
vi --version
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Jun 10 2014 06:56:12)
Included patches: 1-160
Modified by <[email protected]>
Compiled by <[email protected]>
Small version without GUI. Features included (+) or not (-):
... what's included ...
system vimrc file: "/etc/virc"
user vimrc file: "$HOME/.vimrc"
2nd user vimrc file: "~/.vim/vimrc"
user exrc file: "$HOME/.exrc"
fall-back for $VIM: "/etc"
f-b for $VIMRUNTIME: "/usr/share/vim/vim74"
... compilation options ...
Então a pergunta se resume em: Como obtenho o vim para ler meu .vimrc
corretamente?
Editar:
Instalar vim-enhanced
via yum e, em seguida, usar vim
(em oposição a vi
) resolveu o problema, mas ainda assim gostaria de saber se é possível fazer com que ele funcione -a-caixa vi, como instalar vim-enhanced
nem sempre é uma opção. Para referência, aqui está a saída completa das várias informações da versão:
Centos vi:
vi --version
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Jun 10 2014 06:56:12)
Included patches: 1-160
Modified by <[email protected]>
Compiled by <[email protected]>
Small version without GUI. Features included (+) or not (-):
+acl -farsi -mouse_sgr -tag_old_static
-arabic -file_in_path -mouse_sysmouse -tag_any_white
-autocmd -find_in_path -mouse_urxvt -tcl
-balloon_eval -float -mouse_xterm +terminfo
-browse -folding +multi_byte -termresponse
+builtin_terms -footer -multi_lang -textobjects
-byte_offset +fork() -mzscheme -title
-cindent -gettext -netbeans_intg -toolbar
-clientserver -hangul_input -path_extra -user_commands
-clipboard +iconv -perl -vertsplit
-cmdline_compl -insert_expand -persistent_undo -virtualedit
+cmdline_hist +jumplist -printer +visual
-cmdline_info -keymap -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 -sniff -xsmp
-ebcdic -mouse -startuptime -xterm_clipboard
-emacs_tags -mouse_dec -statusline -xterm_save
-eval -mouse_gpm -sun_workshop -xpm
-ex_extra -mouse_jsbterm -syntax
-extra_search -mouse_netterm -tag_binary
system vimrc file: "/etc/virc"
user vimrc file: "$HOME/.vimrc"
2nd user vimrc file: "~/.vim/vimrc"
user exrc file: "$HOME/.exrc"
fall-back for $VIM: "/etc"
f-b for $VIMRUNTIME: "/usr/share/vim/vim74"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -O2 -g -pipe -Wall -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc -Wl,-z,relro -L/usr/local/lib -Wl,--as-needed -o vim -lm -lselinux -lncurses -lacl -lattr -ldl
Centos vim:
vim --version
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Jun 10 2014 06:55:55)
Included patches: 1-160
Modified by <[email protected]>
Compiled by <[email protected]>
Huge version without GUI. Features included (+) or not (-):
+acl +farsi +mouse_netterm +syntax
+arabic +file_in_path +mouse_sgr +tag_binary
+autocmd +find_in_path -mouse_sysmouse +tag_old_static
-balloon_eval +float +mouse_urxvt -tag_any_white
-browse +folding +mouse_xterm -tcl
++builtin_terms -footer +multi_byte +terminfo
+byte_offset +fork() +multi_lang +termresponse
+cindent +gettext -mzscheme +textobjects
-clientserver -hangul_input +netbeans_intg +title
-clipboard +iconv +path_extra -toolbar
+cmdline_compl +insert_expand +perl +user_commands
+cmdline_hist +jumplist +persistent_undo +vertsplit
+cmdline_info +keymap +postscript +virtualedit
+comments +langmap +printer +visual
+conceal +libcall +profile +visualextra
+cryptv +linebreak +python/dyn +viminfo
+cscope +lispindent -python3 +vreplace
+cursorbind +listcmds +quickfix +wildignore
+cursorshape +localmap +reltime +wildmenu
+dialog_con -lua +rightleft +windows
+diff +menu +ruby/dyn +writebackup
+digraphs +mksession +scrollbind -X11
-dnd +modify_fname +signs -xfontset
-ebcdic +mouse +smartindent -xim
+emacs_tags -mouseshape -sniff -xsmp
+eval +mouse_dec +startuptime -xterm_clipboard
+ex_extra +mouse_gpm +statusline -xterm_save
+extra_search -mouse_jsbterm -sun_workshop -xpm
system vimrc file: "/etc/vimrc"
user vimrc file: "$HOME/.vimrc"
2nd user vimrc file: "~/.vim/vimrc"
user exrc file: "$HOME/.exrc"
fall-back for $VIM: "/etc"
f-b for $VIMRUNTIME: "/usr/share/vim/vim74"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -O2 -g -pipe -Wall -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc -L. -Wl,-z,relro -fstack-protector -rdynamic -Wl,-export-dynamic -Wl,--enable-new-dtags -Wl,-rpath,/usr/lib64/perl5/CORE -Wl,-z,relro -L/usr/local/lib -Wl,--as-needed -o vim -lm -lnsl -lselinux -lncurses -lacl -lattr -lgpm -ldl -Wl,--enable-new-dtags -Wl,-rpath,/usr/lib64/perl5/CORE -fstack-protector -L/usr/lib64/perl5/CORE -lperl -lresolv -lnsl -ldl -lm -lcrypt -lutil -lpthread -lc
Ubuntu vim/vi:
vi --version
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Jan 2 2014 19:39:32)
Included patches: 1-52
Modified by [email protected]
Compiled by buildd@
Huge version without GUI. Features included (+) or not (-):
+acl +farsi +mouse_netterm +syntax
+arabic +file_in_path +mouse_sgr +tag_binary
+autocmd +find_in_path -mouse_sysmouse +tag_old_static
-balloon_eval +float +mouse_urxvt -tag_any_white
-browse +folding +mouse_xterm -tcl
++builtin_terms -footer +multi_byte +terminfo
+byte_offset +fork() +multi_lang +termresponse
+cindent +gettext -mzscheme +textobjects
-clientserver -hangul_input +netbeans_intg +title
-clipboard +iconv +path_extra -toolbar
+cmdline_compl +insert_expand -perl +user_commands
+cmdline_hist +jumplist +persistent_undo +vertsplit
+cmdline_info +keymap +postscript +virtualedit
+comments +langmap +printer +visual
+conceal +libcall +profile +visualextra
+cryptv +linebreak +python +viminfo
+cscope +lispindent -python3 +vreplace
+cursorbind +listcmds +quickfix +wildignore
+cursorshape +localmap +reltime +wildmenu
+dialog_con -lua +rightleft +windows
+diff +menu -ruby +writebackup
+digraphs +mksession +scrollbind -X11
-dnd +modify_fname +signs -xfontset
-ebcdic +mouse +smartindent -xim
+emacs_tags -mouseshape -sniff -xsmp
+eval +mouse_dec +startuptime -xterm_clipboard
+ex_extra +mouse_gpm +statusline -xterm_save
+extra_search -mouse_jsbterm -sun_workshop -xpm
system vimrc file: "$VIM/vimrc"
user vimrc file: "$HOME/.vimrc"
2nd user vimrc file: "~/.vim/vimrc"
user exrc file: "$HOME/.exrc"
fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,--as-needed -o vim -lm -ltinfo -lnsl -lselinux -lacl -lattr -lgpm -ldl -L/usr/lib/python2.7/config-x86_64-linux-gnu -lpython2.7 -lpthread -ldl -lutil -lm -Xlinker -export-dynamic -Wl,-O1 -Wl,-Bsymbolic-functions