On Tue, Oct 16, 2012 at 07:08:42AM EDT, monax wrote:

> How I can change this code
> 
> a = 10
> bb = 100
> ccc = 1000
> d = 10000
> 
> to this
> 
> a   = 10
> bb  = 100
> ccc = 1000
> d   = 10000

At a pinch, here's how I'd do it:

| Shift+V
| 3j
| :'<,'>s/ *= */\t=\t/<Enter>
| gv
| :'<,'>retab<Enter>
| 3l
| CTRL+V
| 3l
| 3j
| d
| 3l
| CTRL+V
| 5l
| 3j
| d

*  <S-V> 3j                     : select target lines
*  :'<,'>s/ *= */\t=\t/<Enter>  : spaces -> tabs around equal sign?
*  gv                           : repeat selection 
*  :'<,'>retab<Enter>           : replace tabs by spaces? 
*  3l <C-V> 3l 3j d             : block-select extra spaces & delete them
*  3l <C-V> 5l 3j d             : ibid.

Not as complicated as it seems: apart from <S-V> and <C-V> to select
lines or blocks, it only uses a trivial regex to substitute tabs for
spaces, and the :retab command to change them back to spaces. Most of
the keystrokes are just to move the cursor around.. something you'd have
to do anyway.

CJ

? The '<,'> range that prefixes the Ex-mode commands corresponds to the
  selected lines. You don't type those 5 characters: whenever there is
  an active selection, Vim conveniently does it for you..

-- 
HOW ARE YOU GENTLEMEN?

-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Reply via email to