From f5004fc21eb3bae987324c1e64acdc8e50335672 Mon Sep 17 00:00:00 2001 From: jbranchaud Date: Fri, 16 Oct 2015 09:33:17 -0500 Subject: [PATCH] Add Delete Lines That Match A Pattern as a vim til. --- README.md | 1 + vim/delete-lines-that-match-a-pattern.md | 15 +++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 vim/delete-lines-that-match-a-pattern.md diff --git a/README.md b/README.md index c8a57ce..22dfcda 100644 --- a/README.md +++ b/README.md @@ -232,6 +232,7 @@ smart people at [Hashrocket](http://hashrocket.com/). - [Count the Number of Matches](vim/count-the-number-of-matches.md) - [Create A New Directory In netrw](vim/create-a-new-directory-in-netrw.md) - [Create A New File In A New Directory](vim/create-a-new-file-in-a-new-directory.md) +- [Delete Lines That Match A Pattern](vim/delete-lines-that-match-a-pattern.md) - [Deleting Directories Of Files From netrw](vim/deleting-directories-of-files-from-netrw.md) - [Edges Of The Selection](vim/edges-of-the-selection.md) - [End Of The Word](vim/end-of-the-word.md) diff --git a/vim/delete-lines-that-match-a-pattern.md b/vim/delete-lines-that-match-a-pattern.md new file mode 100644 index 0000000..09bb49f --- /dev/null +++ b/vim/delete-lines-that-match-a-pattern.md @@ -0,0 +1,15 @@ +# Delete Lines That Match A Pattern + +The `:g` command can be used to execute an Ex command over the entire buffer +for all lines that match a given pattern. By choosing `d` (delete) as the Ex +command, all lines that match the given pattern will be deleted. For +instance, if I want to remove all lines that contain `binding.pry`, I can +execute the following command: + +``` +:g/binding\.pry/d +``` + +See `:h :g` for more details. + +h/t Chris Erin