Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Problem: You have some text similar to below and want to align COLUMN B
- Solution: Using vim(1) you can do this in 7 easy steps.
- ############################################################
- LINE COLUMN A COLUMN B
- 1 asd def
- 2 asd def ghi
- 3 boo blech
- 4 11111 asd xx
- 5 --- asd asd asd
- ############################################################
- How to align COLUMN B efficiently using vim?
- Sep 1. :let tabs = "^I^I"
- NB: ^I is TAB (2x TAB is enough in this case)
- Step 2. Position cursor on line 1, start of COLUMN A
- Step 3. Ctrl-V, 4, Down-Arrow
- NB: Selects starting column for 5 lines
- Step 4. :s/\%V[^[:space:]]\{1,\}\zs\ze/\=tabs/
- NB: One more step required to get to aligned COLUMN B
- ############################################################
- Now the text appears as below:
- LINE COLUMN A COLUMN B
- 1 asd def
- 2 asd def ghi
- 3 boo blech
- 4 11111 asd xx
- 5 --- asd asd asd
- ############################################################
- Final steps:
- Step 5. Position cursor on line 1, column under "C" in "COLUMN B"
- Step 6. Ctrl-V, 4, Down-Arrow
- NB: Selects starting column for 5 lines
- Step 7. :s/\%V[[:space:]]*//
- ############################################################
- Now the text appears as below:
- LINE COLUMN A COLUMN B
- 1 asd def
- 2 asd def ghi
- 3 boo blech
- 4 11111 asd xx
- 5 --- asd asd asd
- ############################################################
- Wunderbar!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement