replace string with deleted line

View: New views
7 Messages — Rating Filter:   Alert me  

replace string with deleted line

by engineerCnewbie :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


I have a file that contains a bunch of lines with only the word "foo"
on it.

I want go through the entire file and remove the lines with the words
"foo". Not just remove the word, but the entire line.

How is this done in vim?

I tried :%s/foo//g

but it left the line

thank you!

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


Re: replace string with deleted line

by jreidthompson :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Tue, 2009-11-10 at 08:24 -0800, Jason wrote:

> I have a file that contains a bunch of lines with only the word "foo"
> on it.
>
> I want go through the entire file and remove the lines with the words
> "foo". Not just remove the word, but the entire line.
>
> How is this done in vim?
>
> I tried :%s/foo//g
>
> but it left the line
>
> thank you!
>
> >

$ grep -v foo thefile > newfile

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


Re: replace string with deleted line

by Tinou-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Tue, Nov 10, 2009 at 18:09, Reid Thompson <reid.thompson@...> wrote:

>
> On Tue, 2009-11-10 at 08:24 -0800, Jason wrote:
>> I have a file that contains a bunch of lines with only the word "foo"
>> on it.
>>
>> I want go through the entire file and remove the lines with the words
>> "foo". Not just remove the word, but the entire line.
>>
>> How is this done in vim?
>>
>> I tried :%s/foo//g
>>
>> but it left the line
>>
>> thank you!
>>
>> >
>
> $ grep -v foo thefile > newfile
>

:g/foo/d

Regards

--
Étienne

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


Re: replace string with deleted line

by Tim Chase-9 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


> I want go through the entire file and remove the lines with the words
> "foo". Not just remove the word, but the entire line.
>
> How is this done in vim?
>
> I tried :%s/foo//g
>
> but it left the line

You'd want

   :g/foo/d

-tim



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


Re: replace string with deleted line

by Christian Brabandt-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hi Jason!

On Di, 10 Nov 2009, Jason wrote:

> I want go through the entire file and remove the lines with the words
> "foo". Not just remove the word, but the entire line.

:g/foo/d

regards,
Christian
--
  • It's one of those rare "perfect" kernels. So if it doesn't happen to
    compile with your config (or it does compile, but then does unspeakable
    acts of perversion with your pet dachshund), you can rest easy knowing that
    it's all your own damn fault, and you should just fix your evil ways.
       Torvalds, Linus (2006-11-29).

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


Re: replace string with deleted line

by engineerCnewbie :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


thank you everyone! That is pretty simple! I also appreciate the grep
example.

On Nov 10, 10:14 am, Christian Brabandt <cbli...@...> wrote:

> Hi Jason!
>
> On Di, 10 Nov 2009, Jason wrote:
>
> > I want go through the entire file and remove the lines with the words
> > "foo". Not just remove the word, but the entire line.
>
> :g/foo/d
>
> regards,
> Christian
> --
>   • It's one of those rare "perfect" kernels. So if it doesn't happen to
>     compile with your config (or it does compile, but then does unspeakable
>     acts of perversion with your pet dachshund), you can rest easy knowing that
>     it's all your own damn fault, and you should just fix your evil ways.
>        Torvalds, Linus (2006-11-29).
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---


Re: replace string with deleted line

by engineerCnewbie :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


interestingly, I'm finding gvim might be faster and easier for
manipulating data than a spreadsheet.

On Nov 10, 10:14 am, Christian Brabandt <cbli...@...> wrote:

> Hi Jason!
>
> On Di, 10 Nov 2009, Jason wrote:
>
> > I want go through the entire file and remove the lines with the words
> > "foo". Not just remove the word, but the entire line.
>
> :g/foo/d
>
> regards,
> Christian
> --
>   • It's one of those rare "perfect" kernels. So if it doesn't happen to
>     compile with your config (or it does compile, but then does unspeakable
>     acts of perversion with your pet dachshund), you can rest easy knowing that
>     it's all your own damn fault, and you should just fix your evil ways.
>        Torvalds, Linus (2006-11-29).
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---