
Al editar archivos que limito en mi .vimrc a tw=80, cuando vuelvo a editarlos más tarde, las longitudes de línea terminan por todos lados. p.ej
lets say for the sake of argument that this line hits 80 characters
there and continues on the next line as normal
Después de editar...
lets say for the sake of argument (edit edit edit edit) that this
line hits 80 characters
there and continues on the next line as normal
En lugar de
lets say for the sake of argument (edit edit edit edit) that this
line hits 80 characters there and continues on the next line as
normal
¿Alguien sabe qué puedo hacer para solucionar este comportamiento?
Respuesta1
Puede utilizar el " gq
" comando de modo normal para reformatear el texto. Funciona con una selección visual o con un movimiento. Por ejemplo, puede usar el objeto de texto " ap
" (que puede usarse en lugar de un movimiento) que significa "un párrafo" (el párrafo actual en el que se encuentra el cursor):
gqap
O puede seleccionar visualmente los párrafos que desea reformatear y simplemente escribir " gq
".
Otro truco es agregar "a" y opcionalmente "w" a la opción 'formatoptions':
:set formatoptions+=aw
Esto reformateará automáticamente los párrafos a medida que escriba, sin necesidad de recurrir a " gq
".
Ver:
:help gq
:help auto-format
:help 'formatoptions'
:help motion.txt
Respuesta2
Lo que estás buscando son opciones de formato vi. Para activar el ajuste de texto:
:set fo+= t
Fuentes: