Sunday, December 2, 2012

Re: how can you delete every line between two phrases?

On Sat 17 Nov 2012 12:00:38 PM CST, Tim Chase wrote:
> On 11/16/12 21:22, Tony Mechelynck wrote:
>> The above implements a linewise deletion. For characterwise, you can use
>>
>> :%s/how are you?\zs\_.*\ze:-)//e
>>
>> Notes:
>> - If there are several matching pairs, this subsitute will remove from
>> the first "how are you" to the last ":-)".
>
> Which you can then tweak by changing the "*" to "\{-}"
>
> If you want to do it line-wise and you have multiple instances in
> the file, you can do something like
>
> :g/how are you?/.;/:-)/d
>
> to delete them inclusive, or
>
> :g/how are you?/+;/:-)/-d
>
> (the "+" bumps the starting line forward one from the match, the "-"
> bumps it back one line from the ending match).
>
> And if you have multiple files to do it across, you can use
> windo/bufdo/argdo/tabdo to prefix the command (either setting
> 'hidden' beforehand or writing the file as well)
>
> -tim
>
>

Hi,tim
In :g/how are you?/.;/:-)/d,
Is '/how are you?/.;/:-)/' the pattern in
:[range]g[lobal]/{pattern}/[cmd]?
Would you mind explaining this pattern a little? I don't quite
understand this, thanks.

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