J'essaie de copier ma configuration locale vimrc sur un nouveau serveur linux que je viens de mettre en place :
scp -rp .vim/ nagios:~
scp .vimrc nagios:~
Ensuite, avec ls -hoal
sur la machine distante dans mon ~
répertoire :
drwxr-xr-x 4 <me> 51 Jun 29 13:34 .vim
-rw-r--r-- 1 <me> 431 Jul 7 10:59 .vimrc
Lorsque je lance vim avec vi
(comme il s'agit d'un serveur centos sans lien symbolique pour vim) mon vimrc ne se charge pas.
J'ai trouvé cette question de StackOverflow qui a suggéré plusieurs choses, dont aucune n'a fonctionné. Par exemple :
Dans la réponse acceptée, je peux voir qu'il trouve et lit mon fichier vimrc, pour référence voici mon 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
Et voici ce que je trouve dans le fichier vim strace :
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
Donc on dirait qu'il le trouve, lit quelques lignes, puis meurt.
Cependant, la réponse qui a reçu le plus de votes à cette question suggère quelques autres éléments à vérifier. Lorsque j'exécute :scriptnames
sur mon installation locale (qui fonctionne) de vim, je vois :
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
Et puis d'autres trucs après ça qui chargent tous mes autres plugins ainsi que des trucs dans /usr/share/vim
.
Running :echo $HOME
et/ou :echo $MYVIMRC
fonctionnent également comme prévu.
Cependant, lorsque j'essaie de le faire sur la machine distante, je n'obtiens aucune sortie pour les trois commandes ci-dessus.
Ma machine locale est Xubuntu 14.04 avec cette sortie pour 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 pkg-vim-maintainers@lists.alioth.debian.org
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 ...
Sur la machine distante, j'utilise centos avec la version exacte. centos-release-7-2.1511.el7.centos.2.10.x86_64
et la version de vim :
vi --version
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Jun 10 2014 06:56:12)
Included patches: 1-160
Modified by <bugzilla@redhat.com>
Compiled by <bugzilla@redhat.com>
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 ...
La question se résume donc à : Comment faire pour que vim lise mon .vimrc
correctement ?
Editar:
Installation de vim-enhanced
via yum et ensuite en utilisant vim
(par opposition à vi
) a "résolu" le problème, mais j'aimerais quand même savoir s'il est possible de le faire fonctionner avec un vi prêt à l'emploi, comme l'installation de vim-enhanced
n'est pas toujours une option. Pour référence, voici la sortie complète des différentes informations de version :
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 <bugzilla@redhat.com>
Compiled by <bugzilla@redhat.com>
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 <bugzilla@redhat.com>
Compiled by <bugzilla@redhat.com>
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 pkg-vim-maintainers@lists.alioth.debian.org
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