
Ao editar arquivos que limitei em meu .vimrc a tw = 80, quando volto para editá-los mais tarde, os comprimentos das linhas ficam espalhados por todo o lugar. por exemplo
lets say for the sake of argument that this line hits 80 characters
there and continues on the next line as normal
Depois 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
Em vez 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
Alguém sabe o que posso fazer para corrigir esse comportamento?
Responder1
Você pode usar o gq
comando de modo normal " " para reformatar o texto. Funciona com seleção visual ou com movimento. Por exemplo, você pode usar o objeto de texto " ap
" (que pode ser usado no lugar de um movimento), que significa "um parágrafo" (o parágrafo atual em que o cursor está):
gqap
Ou você pode selecionar visualmente o(s) parágrafo(s) que deseja reformatar e apenas digitar " gq
".
Outro truque é adicionar "a" e opcionalmente "w" à opção 'formatoptions':
:set formatoptions+=aw
Isso reformatará automaticamente os parágrafos conforme você digita, sem a necessidade de recorrer a " gq
".
Ver:
:help gq
:help auto-format
:help 'formatoptions'
:help motion.txt
Responder2
O que você está procurando são opções de formato vi. Para ativar a quebra automática de texto:
:set fo+= t
Fontes: