On Sat, 10 Mar 2012 08:47:38 +0800, Tim Chase <[email protected]> wrote:

On 03/09/12 18:36, Yue Wu wrote:
Hi, list,

I want to delete all regions between line '#begin' and line '#end' in a
buffer, for example, a buffer:
----------------------
#begin
region1
#end

Some text.

#begin
region2
#end

Some text.
Some text.
Some text.
----------------------

will become:
----------------------

Some text.


Some text.
Some text.
Some text.
----------------------
after the operation, how to do it in vim?

There are several variants depending on how closely you want it to match your output with regards to intervening whitespace. The general pattern is something like

   :g/#begin/;/#end/d

to delete just those bits. If you have whitespace around each block and you want to smash that a bit, you can use

   :g/#begin/norm dap

You can tighten up those regexps to "^#begin$" and "^#end$" if you have them in other locations that you want to preserve.

-tim


It works fine well in what I want exactly, thank you and thank you for so quick replying :)


--
Regards,
Yue Wu

State Key laboratory of Natural Products and Functions
Key Laboratory of Modern Chinese Medicines
Department of Traditional Chinese Medicine
China Pharmaceutical University
No.24, Tongjia Xiang Street, Nanjing 210009, China

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

Reply via email to