Tengo dos servidores remotos:
Servidor 1: Linux 2.6.18-238.12.1.el5PAE i686 / VIM - Vi IMproved - versión 7.0.237
Servidor 2: Linux 2.6.18-338.19.1.el5.lve0.8.36 x86_64 / VIM - Vi IMproved versión 7.0. 237
Cuando SSH en el servidor 2 y el uso vim para editar una phpo .htaccessarchivo que tiene un hermoso color de resaltado. A continuación se muestra el /etc/vimrcarchivo en ese servidor.
Cuando ingreso al servidor 1, no aparece ningún color. Intenté copiar el siguiente código en mi archivo ~ / .vimrc en el Servidor 1, pero la sintaxis del color no funciona. Las otras características (como set nocompatible) están funcionando, pero no los colores.
¿Por qué el color no funciona en el Servidor 1 y cómo puedo probarlo y solucionarlo? tput colorsen ambos terminales vuelve 8. Lo intenté :syntax ony :syntax enableeso tampoco ayuda.
------------------------------------------------------------
Contenido del /etc/vimrcarchivo:
if v:lang =~ "utf8$" || v:lang =~ "UTF-8$"
set fileencodings=utf-8,latin1
endif
set nocompatible " Use Vim defaults (much better!)
set bs=indent,eol,start " allow backspacing over everything in insert mode
"set ai " always set autoindenting on
"set backup " keep a backup file
set viminfo='20,\"50 " read/write a .viminfo file, don't store more
" than 50 lines of registers
set history=50 " keep 50 lines of command line history
set ruler " show the cursor position all the time
" Only do this part when compiled with support for autocommands
if has("autocmd")
augroup redhat
" In text files, always limit the width of text to 78 characters
autocmd BufRead *.txt set tw=78
" When editing a file, always jump to the last cursor position
autocmd BufReadPost *
\ if line("'\"") > 0 && line ("'\"") <= line("$") |
\ exe "normal! g'\"" |
\ endif
augroup END
endif
if has("cscope") && filereadable("/usr/bin/cscope")
set csprg=/usr/bin/cscope
set csto=0
set cst
set nocsverb
" add any database in current directory
if filereadable("cscope.out")
cs add cscope.out
" else add database pointed to by environment
elseif $CSCOPE_DB != ""
cs add $CSCOPE_DB
endif
set csverb
endif
" Switch syntax highlighting on, when the terminal has colors
" Also switch on highlighting the last used search pattern.
if &t_Co > 2 || has("gui_running")
syntax on
set hlsearch
endif
if &term=="xterm"
set t_Co=8
set t_Sb=%dm
set t_Sf=%dm
endif
: salida de versión
VIM - Vi IMproved 7.0 (2006 May 7, compiled Aug 4 2010 07:21:18)
Included patches: 1, 3-4, 7-9, 11, 13-17, 19-26, 29-31, 34-44, 47, 50-56, 58-64, 66-73, 75, 77-92, 94-107, 109, 202, 234-237
Compiled by <[email protected]>
Tiny version without GUI. Features included (+) or not (-):
-arabic -autocmd -balloon_eval -browse +builtin_terms -byte_offset -cindent -clientserver -clipboard -cmdline_compl -cmdline_hist -cmdline_info -comments -cryptv -cscope -cursorshape -dialog -diff -digraphs -dnd -ebcdic -emacs_tags -eval -ex_extra -extra_search -farsi
-file_in_path -find_in_path -folding -footer +fork() -gettext -hangul_input +iconv -insert_expand -jumplist -keymap -langmap -libcall -linebreak -lispindent -listcmds -localmap -menu -mksession -modify_fname -mouse -mouse_dec -mouse_gpm -mouse_jsbterm -mouse_netterm
-mouse_xterm +multi_byte -multi_lang -mzscheme -netbeans_intg -osfiletype -path_extra -perl -printer -profile -python -quickfix -reltime -rightleft -ruby -scrollbind -signs -smartindent -sniff -statusline -sun_workshop -syntax -tag_binary -tag_old_static -tag_any_white
-tcl +terminfo -termresponse -textobjects -title -toolbar -user_commands -vertsplit -virtualedit -visual -viminfo -vreplace +wildignore -wildmenu -windows +writebackup -X11 -xfontset -xim -xsmp -xterm_clipboard -xterm_save
system vimrc file: "/etc/virc"
user vimrc file: "$HOME/.vimrc"
user exrc file: "$HOME/.exrc"
fall-back for $VIM: "/usr/share/vim"
Compilation:
gcc -c -I. -Iproto -DHAVE_CONFIG_H -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2
Linking: gcc -L/usr/local/lib -o vim -lselinux -ltermcap -lacl

:set term,:set filetypey nos dará el resultado.Respuestas:
Sospecho que usted tiene una
alias vim=vien~/.bashrc. Pruebe esto para ejecutar el comando 'real', no el alias:Parece que estás ejecutando CentOS. Asegúrese de haber instalado el
vim-enhancedpaquete:fuente
Puede ver por su salida de versión de vim que es vim-tiny y no está compilado con la
-syntaxopción.También ponga
export TERM=xterm-256coloren su bashrc para obtener el beneficio completo ...fuente
También puede usar
sshfspara montar el recurso para que su vim local se use para editar estos archivos.Vim también puede editar archivos remotos. La belleza de esto es que luego puede editar en la comodidad de su propia configuración vim personalizada y familiar.
vi scp://[email protected]/path/to/filefuente
Hay un caso específico en el que si su terminal de cliente no establece un TERM de color, sino que establece COLORTERM. Hacer esto:
En la máquina cliente, agregue
SendEnv COLORTERMen/etc/ssh/ssh_config, y en el servidor, añadirAcceptEnv COLORTERMen/etc/ssh/sshd_config.service sshd reloadVuelva a cargar sshd ( ) y vuelva a conectar.Si su servidor es CentOS / RHEL y tiene
/etc/profile/256term.sh(proporcionado por el paqueteinitscripts), que el mío hizo de forma predeterminada, esto debería establecerse automáticamenteTERMenxterm-256color, habilitar el color en bash (ls ...) y permitir que el color en vim.Como ya señaló quanta si solo tiene vi, instale vim-enabled.
No estoy seguro de si esto es necesario si su terminal de cliente ya establece un TERM de color. Tuve que hacer esto para evitar que Terminator tuviera un TERM = xterm codificado. gnome-terminal en ubuntu tiene un TERM predeterminado xterm-256color, por lo que el color puede funcionar sin necesidad de Send / AcceptEnv en ssh.
fuente
Creo que en realidad puede tener vi y no vim mejorado en la consola que tiene SSH'd. Tuve que instalar o alias vim to vi y funcionó normalmente para mí. La "E519: Opción no admitida: tipo de archivo" en su comentario, revela esta información.
Encontré información útil sobre esto aquí .
fuente