Last active
August 29, 2015 14:02
-
-
Save hectorperez/056967d96e09481fb40e to your computer and use it in GitHub Desktop.
Delete all lines containing a pattern in Vim
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# to delete all lines containing "profile" (remove the /d to show the lines that the command will delete): | |
:g/profile/d | |
# to delete all lines that do not contain a pattern, use 'g!' (equivalent to 'v'), like this command to delete all lines that are not comment lines in a Vim script: | |
:g!/^\s*"/d | |
:v/^\s*"/d | |
# to delete all lines except those that contain "error" or "warn" or "fail" | |
:v/error\|warn\|fail/d | |
# http://vim.wikia.com/wiki/Delete_all_lines_containing_a_pattern |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment