Usando o vim para criar texto de largura fixa?

Usando o vim para criar texto de largura fixa?

Eu tenho texto no formulário

xxxx  yyyyy
xx yyyy
xxxxxxxx  yyyyy
x y

Eu gostaria que o segundo conjunto em cada linha começasse no mesmo ponto, ou seja

xxxx      yyyyy
xx        yyyy
xxxxxxxx  yyyyy
x         y

Não consigo pensar em uma solução elegante usando o vim e sempre me incomoda quando invisto mais tempo em uma solução do que seria necessário para fazer algo manualmente. Sempre posso armazená-lo para a próxima vez, se alguém tiver uma solução inteligente!

Responder1

Eu vi alguns truques inteligentes de localização/substituição que dariam conta do recado, mas não posso, de forma alguma, guardá-los na memória, então isso é uma coisa que eu uso(e recomendo)um plug-in.

UsandoAlinhar, isso passa a ser um mero

- VG                (select all)
- <leader>tsp       (align whitespace)

Da ajuda

    ---------------------------         *alignmap-Tsp*
    Alignment Map Examples: \tsp            *alignmap-tsp* {{{3
    ---------------------------

    Normally Align can't use white spaces for field separators as such
    characters are ignored surrounding field separators.  The \tsp and
    \Tsp maps get around this limitation.

    Original: >
     one two three four five
     six seven eight nine ten
     eleven twelve thirteen fourteen fifteen
<
    Becomes: Select the lines, \tsp >
     one    two    three    four     five
     six    seven  eight    nine     ten
     eleven twelve thirteen fourteen fifteen
<
    Becomes: Select the lines, \Tsp >
        one    two    three     four    five
        six  seven    eight     nine     ten
     eleven twelve thirteen fourteen fifteen
<

informação relacionada