On 01/03/09 18:41, StarWing wrote:
>
>> I have hundreds of rows in a files like:
>>
>> ALTER TABLE "PCDTST"."ACCOUNTINGSTATUS" ADD CONSTRAINT
>> "PK_ACCOUNTINGSTATUS" PRIMARY KEY ("ACCOUNTINGSTATUS") USING INDEX PCTFREE
>> 10 INITRANS 2 MAXTRANS 255 STORAGE(INITIAL 65536 FREELISTS 1 FREELIST
>> GROUPS 1) TABLESPACE "PESDBO_INDEXES" LOGGING ENABLE ;
>>
>> how can I change to: (just delet 'USING' clause till ';' in each line)
>>
>> ALTER TABLE "PCDTST"."ACCOUNTINGSTATUS" ADD CONSTRAINT
>> "PK_ACCOUNTINGSTATUS" PRIMARY KEY ("ACCOUNTINGSTATUS");
>
> maybe
> :%s/USING \zs[^;]\ze;//g
>
> or
> :%s/USING \zs.\{-}\ze\s*;\s*$//g
>
> you can choose one for try...
Due to \zs, the above won't remove the USING word itself.
The command
:%s/\<USING\>\_.\{-}\ze;//g
will delete everywhere from USING (included) to the _first_ following
semicolon (excluded) regardless of how many or how few intervening
linebreaks there might be. USING must be present as a separate word:
something like HOUSING won't trigger the substitute.
Note the use of:
\< start of word
\> end of word
\_. anything including a linebreak
\{-} 0 or more, as few as possible
\ze the replaceable match ends here
g flag any number of times on a line
This assumes that quoted semicolons (which we must skip) won't happen
among the operands of USING.
Bestregards,
Tony.
--
Toilet Toupee, n.:
Any shag carpet that causes the lid to become top-heavy, thus
creating endless annoyance to male users.
-- Rich Hall, "Sniglets"
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---