Friday, January 28, 2011

Re: Indpendant position marks for scripts ?

On 29/01/11 3:42 PM, meino.cramer@gmx.de wrote:
>
> Hi,
>
> I want to process a text with script.
> The text contains of two regions:
> The first region contains of lines beginning with keyword_a
> and the second one start with keyword_b.
> I want to sort the first region using sort with pattern_a and
> after that I want to sort the second region with pattern_b.
>
> I can set the start of the forst sort with
>
> : /keyword_a
>
> in the script. But I dont know how to limit the range of the first
> sort so that only lines starting with keyword_a are sorted using
> pattern_a. Same goes for the second region...

Try something like

:0/^a/,/^\(a\)\@!/sort

It means loosely:

: - perform an ex command
0 - from before the beginning of the file
/^keyword_a/ - find a line beginning with 'keyword_a'
, - and operate until
/ - we find
^ - the beginning of a line
\(keyword_a\)\@! - where 'keyword_a' doesn't match
/sort - with the sort command

Ben.

--
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

No comments:

Post a Comment