create rules in vim

14 views
Skip to first unread message

Martín Riesco

unread,
Sep 17, 2020, 10:09:03 AM9/17/20
to vim_use
Hola, tengo una duda que quisiera ver si me pueden ayudar. Quisiera saber como crear 'reglas' en los archivos que edito en vim, segun el tipo de archivo que sea, alguna de las cosas que quiero hacer por ejemplo:
-Si el archivo es HTML, que cuando coloque <> se cree automaticamente el tag de cierre y se vaya autocompletando mientras yo completo el de arriba.
-SI el archivo es CSS y escribo {}, que automaticamente me los ingrese con un renglon de por medio y con el cursor ahi para poder seguir escribiendo con el archivo ya formateado.
-Si estoy escribiendo en React, quiero tener mis snippets personalizados.

Y asi mucho mas, he probado con plugins de autocomplete de tag de html, snippets de react, etc, pero por alguna razon no funcionan bien o no me andan algunos, y he decidido inclinarme por el lado de aprender a hacer mis reglas para poder aplicar de aca a un futuro.

Desde ya muchas gracias, y que tengan un excelente dia. Saludos!!!

BPJ

unread,
Sep 17, 2020, 12:10:58 PM9/17/20
to vim_use
(Traducido al español con el traductor de Google debajo del inglés)

I like surround.vim <https://git.io/surround.vim>.

It is not totally automatic but on the other hand it also allows you to change HTML tags or brackets ( ) { } [ ] < > very easily.

With the plugin enabled to create an HTML tag you just type CTRL-s + < then type everything which should go inside the opening tag in the command line, for example p class="foo" then press Return and you get <p class="foo">|</p> (with | showing the cursor between the tags). To get the tags on separate lines with the cursor on a line between them just type CTRL-s + Return + < and type the tag in the command line and then Return again.

To get {|} with the cursor between two brackets just type CTRL-s + } and to get { | } with extra white space type CTRL-s + { and finally to get the { } on their own lines just type CTRL-s + Return + }

If you for example typed <em>Warning</em> and decide you wanted strong emphasis instead just place the cursor between the tags and type c + s + t + < type strong then Return and the tag changes.

See the manual at <https://git.io/JURSX>

To translate the web pages just go to <translate.google.com>, paste the address in the text field and press the arrow which appears.

Me gusta surround.vim <https://git.io/surround.vim>.

 No es totalmente automático, pero por otro lado también le permite cambiar etiquetas HTML o corchetes () {} [] <> muy fácilmente.

 Con el complemento habilitado para crear una etiqueta HTML, simplemente escriba CTRL-s + <luego escriba todo lo que debe ir dentro de la etiqueta de apertura en la línea de comando, por ejemplo p class = "foo", luego presione Retorno y obtendrá <p class =  "foo"> | </p> (con | mostrando el cursor entre las etiquetas).  Para obtener las etiquetas en líneas separadas con el cursor en una línea entre ellas, simplemente escriba CTRL-s + Return + <y escriba la etiqueta en la línea de comando y luego Return nuevamente.

 Para obtener {|} con el cursor entre dos corchetes, simplemente escriba CTRL-s +} y para obtener { | } con espacio en blanco adicional, escriba CTRL-s + {y, finalmente, para obtener el {} en sus propias líneas, simplemente escriba CTRL-s + Retorno +}

 Si, por ejemplo, escribió <em> Advertencia </em> y decide que desea un énfasis fuerte en su lugar, simplemente coloque el cursor entre las etiquetas y escriba c + s + t + <escriba strong, luego Retorno y la etiqueta cambia.

 Consulte el manual en <https://git.io/JURSX>

 Para traducir las páginas web, vaya a <translate.google.com>, pegue la dirección en el campo de texto y presione la flecha que aparece.
Reply all
Reply to author
Forward
0 new messages