Incapaz de averiguar algunas configuraciones de vimrc

I came across the following lines in a vimrc file and can't figure out what they're supposed to do or how they're supposed to work. Am thrown off by the use of the $ sign. Does it have any special meaning or is it used in a regular manner like any other character?

" Parenthesis/bracket expanding
vnoremap $1 <esc>`>a)<esc>`<i(<esc>
vnoremap $2 <esc>`>a]<esc>`<i[<esc>
vnoremap $3 <esc>`>a}<esc>`<i{<esc>
vnoremap $$ <esc>`>a"<esc>`<i"<esc>
vnoremap $q <esc>`>a'<esc>`<i'<esc>
vnoremap $e <esc>`>a"<esc>`<i"<esc>

" Map auto complete of (, ", ', [
inoremap $1 ()<esc>i
inoremap $2 []<esc>i
inoremap $3 {}<esc>i
inoremap $4 {<esc>o}<esc>O
inoremap $q ''<esc>i
inoremap $e ""<esc>i
inoremap $t <><esc>i

If anyone's interested. Este planteamiento de « is the link to the vimrc

preguntado el 10 de marzo de 12 a las 07:03

:h mapmodes puede ser útil. -

Andrew, I'm familiar with the way mappings work. I'm not sure what the $ sign means here. I didn't find the answer in mapmode. Is there some particular sub-section I should be looking out for? -

El $ is not particularly special, it's just the first key (of two) in the sequence of the left-hand-side of the mapping. See my answer for a fuller explanation. -

I recommend Tim Pope's excellent envolvente.vim to handle most of these mappings -

@Michael I'm using surround.vim. Just stumbled upon this vimrc and was going through it to see if I could learn something new; I did. -

1 Respuestas

Looking at just two of these.

El primero es un visual-mode mapping:

" Parenthesis/bracket expanding
vnoremap $1 <esc>`>a)<esc>`<i(<esc>

This wraps the selection in () cuando escribes $1. First it jumps to the end of the selection ('>) y agastars una ) before jumping to the beginning of the selection ('<) y iinsertaring a (.

Esta es una insert-mode mapping:

" Map auto complete of (, ", ', [
inoremap $1 ()<esc>i

Esto inserta () cuando escribes $1 and leaves the cursor in between the two parentheses.

respondido 10 mar '12, 08:03

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.