Pregunta

El "partido" se supone que el complemento para vim le permite usar la tecla % para saltar entre las etiquetas de inicio / fin coincidentes al editar HTML, así como / * y * / delimitadores de comentarios al editar otros tipos de código.

He seguido las instrucciones exactas en " : help matchit " ;, pero % todavía no funciona para mí.

Parece una tontería preguntar "¿Por qué esto no funciona?" así que, en cambio, pregunto ¿Cómo puedo diagnosticar el problema? Los punteros a referencias son bienvenidos, pero se prefieren técnicas específicas de depuración de plugins vim.

Aquí está el directorio ~ / .vim:

$ ls -ltaGR ~/.vim
/cygdrive/y/.vim:
total 0
drwxr-xr-x 1 spause 0 Sep 17 13:20 ..
drwxr-xr-x 1 spause 0 Sep 16 13:59 doc
drwxr-xr-x 1 spause 0 Sep 16 13:58 .
drwxr-xr-x 1 spause 0 Sep 16 13:58 plugin

/cygdrive/y/.vim/doc:
total 24
-rw-r--r-- 1 spause  1961 Sep 16 13:59 tags
drwxr-xr-x 1 spause     0 Sep 16 13:59 .
-rw-r--r-- 1 spause 19303 Sep 16 13:58 matchit.txt
drwxr-xr-x 1 spause     0 Sep 16 13:58 ..

/cygdrive/y/.vim/plugin:
total 32
drwxr-xr-x 1 spause     0 Sep 16 13:58 ..
-rw-r--r-- 1 spause 30714 Sep 16 13:58 matchit.vim
drwxr-xr-x 1 spause     0 Sep 16 13:58 .

Estoy ejecutando vim 7.2 bajo Cygwin (instalado en otoño de 2008). cygcheck muestra:

1829k 2008/06/12 C:\cygwin\bin\cygwin1.dll
Cygwin DLL version info:
    DLL version: 1.5.25
    DLL epoch: 19
    DLL bad signal mask: 19005
    DLL old termios: 5
    DLL malloc env: 28
    API major: 0
    API minor: 156
    Shared data: 4
    DLL identifier: cygwin1
    Mount registry: 2
    Cygnus registry name: Cygnus Solutions
    Cygwin registry name: Cygwin
    Program options name: Program Options
    Cygwin mount registry name: mounts v2
    Cygdrive flags: cygdrive flags
    Cygdrive prefix: cygdrive prefix
    Cygdrive default prefix:
    Build date: Thu Jun 12 19:34:46 CEST 2008
    CVS tag: cr-0x5f1
    Shared id: cygwin1S4

En vim, : set muestra:

--- Options ---
  autoindent          fileformat=dos      shiftwidth=3
  background=dark     filetype=html       syntax=html
  cedit=^F            scroll=24           tabstop=3
  expandtab           shelltemp           textmode
  viminfo='20,<50,s10,h

Notablemente, la sintaxis y el tipo de archivo se reconocen como HTML. (El color de la sintaxis está bien).

Si se necesita información adicional, comente.

ACTUALIZACIÓN:

Por respuesta por demasiado php :

Después de intentar vim -V1 , había cambiado mi .vimrc para incluir una línea

set nocp

por lo que la opción compatible no está activada.

: deje que loadad_matchit

loaded_matchit        #1

: establecer runtimepath?

runtimepath=~/.vim,/usr/share/vim/vimfiles,/usr/share/vim/vim72,/usr/share/vim/vimfiles/after,~/.vim/after

( ~ es / cygdrive / y )

Por respuesta de michael :

:scriptnames

  1: /cygdrive/y/.vimrc
  2: /usr/share/vim/vim72/syntax/syntax.vim
  3: /usr/share/vim/vim72/syntax/synload.vim
  4: /usr/share/vim/vim72/syntax/syncolor.vim
  5: /usr/share/vim/vim72/filetype.vim
  6: /usr/share/vim/vim72/colors/evening.vim
  7: /cygdrive/y/.vim/plugin/matchit.vim
  8: /cygdrive/y/.vim/plugin/python_match.vim
  9: /usr/share/vim/vim72/plugin/getscriptPlugin.vim
 10: /usr/share/vim/vim72/plugin/gzip.vim
 11: /usr/share/vim/vim72/plugin/matchparen.vim
 12: /usr/share/vim/vim72/plugin/netrwPlugin.vim
 13: /usr/share/vim/vim72/plugin/rrhelper.vim
 14: /usr/share/vim/vim72/plugin/spellfile.vim
 15: /usr/share/vim/vim72/plugin/tarPlugin.vim
 16: /usr/share/vim/vim72/plugin/tohtml.vim
 17: /usr/share/vim/vim72/plugin/vimballPlugin.vim
 18: /usr/share/vim/vim72/plugin/zipPlugin.vim
 19: /usr/share/vim/vim72/syntax/html.vim
 20: /usr/share/vim/vim72/syntax/javascript.vim
 21: /usr/share/vim/vim72/syntax/vb.vim
 22: /usr/share/vim/vim72/syntax/css.vim

Tenga en cuenta que matchit.vim, html.vim, tohtml.vim, css.vim y javascript.vim están presentes.

: echo b: match_words

E121: Undefined variable: b:match_words
E15: Invalid expression: b:match_words

Hm, esto parece muy relevante. Ahora estoy mirando a través de : help matchit-debug para averiguar cómo solucionar b: match_words .

¿Fue útil?

Solución

Gracias a esta publicación de lista de correo vim_use , encontré una secuencia de comandos que funciona:

vim -u NONE somefile.html

(esto inicia vim sin leer .vimrc)

Entonces,

:set nocp
:source /usr/share/vim/vim72/macros/matchit.vim
:filetype plugin on
:filetype detect
:syntax on

No es ideal, pero no parece funcionar desde .vimrc. Y no funciona cuando syntax on precede a la detección del tipo de archivo, por lo que sospecho que hay un conflicto en la interacción entre el material de resaltado de sintaxis y el material coincidente.

Otros consejos

Use el siguiente comando para ver si se cargó el complemento:

:let loaded_matchit

Si obtiene un error variable indefinido, entonces el complemento no se cargó, debe asegurarse de que '/cygdrive/y/.vim' esté en su opción 'runtimepath' (use ': set runtimepath? ')

También tenga en cuenta que el complemento matchit no se carga si la opción 'compatible' está activada.

Es posible que desee leer : he matchit . La sección sobre configuración podría ayudar.

: he matchit-debug - información de depuración específica para matchit

: él depura - depuración general de vim (puede hacer todo tipo de punto de interrupción / paso a través de cosas)

Un problema común (aunque no es su caso) es que el tipo de archivo html se puede cortar si está utilizando un complemento de plantilla. (Por ejemplo, mi html se convierte en html.djangotemplate) Intente : set ft? para encontrar su tipo de archivo. es posible que deba copiar b: match_words en ftplugin para el tipo de archivo de plantilla.

: echo b: match_words - debería dar una lista de html buscando expresiones regulares

también en el caso del obvio : scriptnames debería mostrar matchit.vim en algún lugar

Buena suerte

No tengo idea sobre vim (además de usarlo mucho), pero descubrí que poner las dos líneas siguientes en mi .vimrc ayudó mucho:

:source /usr/share/vim/addons/plugin/matchit.vim
:source /usr/share/vim/vim72/ftplugin/html.vim

Estoy seguro de que hay una forma adecuada, pero al menos esto funcionó para mí.

Saludos,

Joerg

Obtuve los comandos anteriores para trabajar en mi .vimrc eliminando la mayor parte de la otra basura en ~ / vim, como ~ / .vim / ftdetect y ~ / .vim / ftplugin. Comience con un ~ / .vim limpio y solo copia lo que es específico para ti, evitando todo lo que pueda tener una versión más nueva en $ VIMRUNTIME, y debería funcionar.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top