On Fri, Nov 16, 2012 at 7:35 PM, Ant <[email protected]> wrote:

> Hello all,
>
> I am starting to see the power of VIM! But I am still so new at it all so
> would like some help.
>
> I am trying to do something, here is an example
>
> ==============================
> Extremely large document.txt
> hello little cat.
> how are you?
> I hope you
> are
> well today.
> :)
> Hello world!
> ==============================
>
> how would you delete every line in between "how are you?" and ":)"??
>
> is there an easy way to do it for several hundred text documents? An
> example of my use is deleting text between two unique numbers that occur on
> hundreds of text documents, and have different content in each. Actually I
> wouldnt mind being able to get all that content out onto another text file.
>
> THANKS!!
>
>
The deletion command:

:/^how are you?$/+1,/^:)$/-1d

This defines a range starting with the line immediately after the line
matching "^how are you?$" (that's the +1) and just before the line matching
"^:)$" (the -1 bit) and deletes it using the "d" command. If you wanted to
delete the two matching lines, also, then you would leave out the offsets.

Bear in mind that this works just like the standard search command (/) and
works on the next matching range after the cursor; if you have multiple
matches in one file, stick a g before the whole thing (:g/^how...).

While Vim is an editor and not meant to handle multiple files in this
fashion, in my opinion, you could probably use :bufdo, :argdo, :windo or
:tabdo (most likely argdo) to make it happen across a number of files.

I wonder if sed might be better for this task; the syntax for the command
would probably be similar.

Hope this helps,

Salman

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