[prev in list] [next in list] [prev in thread] [next in thread] 

List:       vim
Subject:    Re: Can I indent more?
From:       Gary Johnson <garyjohn () spk ! agilent ! com>
Date:       2003-04-30 6:28:25
[Download RAW message or body]

On 2003-04-29, Saar Machtinger <SAARMA@Amdocs.com> wrote:
> Hi,
> 
> I have inside my C files, many declarations
> e.g.
>   SUBNO_C_D       (subscriber_no);
>   PRODTP_C_D      (product_type);
>   SUBCSMSTS_C_D   (sub_status);
>   DATE_C_D        (sub_status_date);
>   DATE_C_D        (init_activation_date);
>   parrfmind_t     rfmArr;
>   SOC_C_D         (old_pp);
>   DLRCD_C_D       (dealer_code); 
> 
> How can I indent them so they will be:
>   SUBNO_C_D             (subscriber_no);
>   PRODTP_C_D          (product_type);
>   SUBCSMSTS_C_D   (sub_status);
>   DATE_C_D                (sub_status_date);
>   DATE_C_D                (init_activation_date);
>   parrfmind_t                 rfmArr;
>   SOC_C_D                 (old_pp);
>   DLRCD_C_D            (dealer_code); 

Besides the Align script, another, perhaps more straightforward way
to move that second column is to use the blockwise-visual mode to
insert a column of spaces and/or tabs in front of it.  To do that,
move the cursor to the '(' in the first line and type Ctrl-V.  Then
type 'j' enough times to highlight that column down to the last line
of the declarations.  Then type 'I' followed by enough spaces and/or
tabs to indent the first line the way you want, then type Esc and
voila, all the other lines will be indented the same way.  See

    :help blockwise-visual

If you are going to do this in a lot of places in your code, it
might be worthwhile to use a substitute command instead, e.g.,

    :s/^\(\s*\S\+\s\+\)\(\S.*\)/\1     \2/

where the spaces between the "\1" and the "\2" are inserted ahead of
the second column in every line to which you apply the command.  For
example, you could use linewise-visual mode (entered by typing 'V')
to select a set of declarations, then type the substitute command
above starting with the ':'.

HTH,
Gary

-- 
Gary Johnson                 | Agilent Technologies
garyjohn@spk.agilent.com     | Wireless Division
                             | Spokane, Washington, USA
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic