> is it possible and if 'yes' to do the following:
> 
> In a text of paragraphs, there are paragraphs containing
> a certain keyword.
> I want to delete all lines of all paragraphs containing 
> the keyword except the lines containing the keyword.
> And I want to delete all paragraphs containing no keyword
> completly.
> And I want to delete all paragraphs consisting only lines
> containing the keyword.

With some constraints on your input, yes.

Constraint: All lines of a paragraph begin at the start-of-line 
(no indented lines)

   " indent those paragraphs containing "backup"
   :sil!  g/backup/'{,'}>

   " delete those lines/paragraphs that didn't get marked
   :g/^\S/d

   " purge out those lines containing the keyword
   :g/backup/d

   " unindent the lines back to their original
   :%s/^\s\+

   " clean up any stray blank lines:
   :g/^\s*$/d


Your source text adheres to the above constraint, so hopefully 
this works for you.  This is a variant of the "decorate, sort, 
undecorate" pattern -- in this case a "decorate, process, 
undecorate".

-tim




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

Reply via email to