VIm Question ...
Jorge Almeida
jjalmeida at gmail.com
Thu Oct 18 00:55:30 PDT 2007
On 10/17/07, Ben Duncan <linux4ms at aim.com> wrote:
> I need to know the command to delete lines that DO NOT contain a string.
>
> For example, I have lines that contain the strings in them "works_1", "works_2",
> "works_3" and so on.
>
> I want to hight light the rows and then delete the rows that DO NOT have
> the string "works_4" in them.
Try
! grep -v works_4
You probably know this, but anyway: when in visual mode, the ! calls
the shell to execute a command (grep -v) with the highlighted part as
standard input, and the highlighted zone is replaced by the external
program's output.
This does what you want, although it doesn't answer your question. I
have no idea how to do it with vim buildins.
Jorge Almeida
More information about the Linux-users
mailing list