Reputation: 2135
I have word lists where the word or expression in Spanish is separated by its translation with a colon (":"). I want to make two columns, one for Spanish, the other for English. In vim I tried with
:%s/:/^I^I^I/g
But it does not give the desired output. The different columns are not aligned.
When deleting the colon by hand and inserting the number of tabs with the same amount of tab strokes, it always ends up aligned.
Any idea how to solve this, preferably in vim?
Upvotes: 5
Views: 3418
Reputation: 17198
On a Linux/*nix system I use column(1)
:%!column -s':' -t
followed by
:%retab!
Upvotes: 4
Reputation: 59327
With Tabular.vim it's quite easy, just type :Tab /:\zs
and it does the rest.
Upvotes: 1
Reputation: 40613
I'd probable do a
:s/:/^I/g
followed by a
:set ts=25
Where 25 is the length of the longest word expected + 2. So, if you expect the longest word of your input (on the left side of the colon) to be 12 characters, I'd choose something around 14 instead.
Upvotes: 2
Reputation: 79243
When in insert mode a setting of yours makes tab to reach a nth column. This is set with the 'softtabstop'
settings if I am right.
For those tasks you could use a plugin like Align.vim or Tabularize.
Another option is to insert a huge number of spaces, and then use Visual Block with <
operator as many times as necessary, if you have to do it once. Otherwise prefer reusable methods.
Upvotes: 0