Problema inexplicável de indentação gq


11

Eu insiro este texto no Vim:

t tttt ttttttttt tt tttt tt ttt tttttt-tttt-ttttttt
tttttttttttttttttttttttttttttttttttttttttttttttttttttt ttttt ttt ttt tttttt
ttttttt tttt ttttttt: ttttttt tt ttttttt, ttttttt tt tttttt, tttttt tt ttttttt,
tttttt tt tttttt ttt. t tttttt tt ttt (tttt) ttttttt-tttttt-tt-ttttttt tttttt
for the "tttttt in ttttttt" part of the issue (in the previous week I have
worked on the "objects in objects" part). This part is about making it
possible for the end user to add arrays in objects. First of all I checked
that the current implementation allows putting arrays in objects at least
from the schema passed to the plugin constructor.

então eu seleciono visualmente todas essas linhas e pressione gq. O conteúdo se torna:

t tttt ttttttttt tt tttt tt ttt tttttt-tttt-ttttttt
tttttttttttttttttttttttttttttttttttttttttttttttttttttt ttttt ttt ttt tttttt
ttttttt tttt ttttttt: ttttttt tt ttttttt, ttttttt tt tttttt, tttttt tt ttttttt,
tttttt tt tttttt ttt. t tttttt tt ttt (tttt) ttttttt-tttttt-tt-ttttttt tttttt
for the "tttttt in ttttttt" part of the issue (in the previous week I have
    worked on the "objects in objects" part). This part is about making it
    possible for the end user to add arrays in objects. First of all I checked
    that the current implementation allows putting arrays in objects at least
    from the schema passed to the plugin constructor.

Por favor, explique-me por que existe esse espaço em branco no início das últimas quatro linhas. É possível que a primeira palavra ( for) na quinta linha, que em algumas linguagens de programação inicie um forloop, faça o Vim pensar que deve iniciar um novo bloco de código recuado, mesmo que essas linhas estejam em um arquivo não salvo ou em um arquivo Markdown ? Como posso evitar esse comportamento e gqparar de inserir esse espaço em branco?

Minha commentsconfiguração tem o valor padrão: s1:/*,mb:*,ex:*/,://,b:#,:%,:XCOMM,n:>,fb:-. Você pode ver meu .vimrcarquivo aqui .

Atualização: Minha opção fo( formatoptions) tem o valor tcq, as opções formatexpre formatprgestão vazias.


E se o arquivo é salvo / não é novo, há alguma diferença?
Gabriel Petrovay

É o mesmo comportamento.
silviubogan

Em seguida, você pode remover essas informações do texto para simplificar o problema.
Gabriel Petrovay

@GabrielPetrovay, obrigado pelo feedback! :-)Eu atualizei a pergunta.
silviubogan

qual é a sua opção 'fo' e a opção 'formatexpr' e formatprg?
Christian Brabandt

Respostas:


18

O problema é que você configurou o smartindentseu ~/.vimrc. As smartindentopções fazem com que o Vim assuma que seu texto é uma linguagem de programação semelhante a C ao recuar. Entre outras coisas, trata forcomo uma palavra-chave e fornece um nível extra de indentação para a linha seguinte. Vejo

:help 'smartindent'
:help 'cinwords'
Ao utilizar nosso site, você reconhece que leu e compreendeu nossa Política de Cookies e nossa Política de Privacidade.
Licensed under cc by-sa 3.0 with attribution required.