Replace the ":" tab to make the columns

I have lists of words where a word or expression in Spanish is separated by its colon translation (":"). I want to make two columns, one for Spanish and one for English. I tried using

:%s/:/^I^I^I/g 

But he does not give the desired result. Different columns are not aligned. However, when you delete a colon manually and insert the number of tabs with the same number of tab steps, it always ends with alignment ...

Any idea how to solve this problem, preferably in vim?

+4
source share
5 answers

On a Linux / * nix system, I use column (1)

 :%!column -s':' -t 

followed by

 :%retab! 
+4
source

I would suggest that

 :s/:/^I/g 

and then

 :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 would choose something around 14 instead.

+2
source

Check out the Align plugin for vim.

http://www.vim.org/scripts/script.php?script_id=294

+1
source

When in insert mode, your setup makes a tab to reach the column n th . This installs with the 'softtabstop' settings, if I'm right.

For these tasks you can use a plugin like Align.vim or Tabularize.

Another option is to insert a huge amount of spaces, and then use the Visual Block with the < operator as many times as necessary if you need to do this once. Otherwise, reusable methods are preferred.

0
source

With Tabular.vim, it's pretty simple, just type :Tab /:\zs , and everything else.

0
source

Source: https://habr.com/ru/post/1337816/


All Articles