Monday, November 30, 2009

Re: How to beautify/tablize some C code

On Mon, Nov 30, 2009 at 12:38:01AM EST, Robert Bu wrote:
> Hi,
>
> For example, I have some C code:
> helloa;
> helloab;
> hellofgh;
>
> Is there a way to change the C code into the form, which looks like:
> helloa ;
> helloab ;
> hellofgh ;
> Where the semicolon is at a "TAB" position. So that I can use
> block-insert to insert some code, such as:
> helloa ("helloa ");
> helloab ("helloab ");
> hellofgh ("hellofgh ");

I would do something like:

1. Ctrl-V + movement to select block
2. hit $ to extend selection to end of line
3. type :s/;$/<Tab><Tab><Tab><Tab>;<Enter>

Note: <Tab> means you hit the tab key, and should display as ^I

You should see something like:

:'<,'>s/;$/^I^I^I^I^I; before you

Some of the ';' will probably be misaligned, but this shouldn't be a
problem if you just want to do some block-inserts, anyway (?).

CJ

--
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php

No comments: