Search code examples
vimhighlighting

Delete lines with highlighted text / delete highlighted text


Does anyone know how to delete:

  1. lines with highlighted text
  2. all highlighted text self

(highlighted text (p.e. after a search) not selected text)


Is there a command which search all highlighted text and delete the line? (independent which search command or function I used to highlight text)

the g/pattern/d command does not always delete the highlighted text
p.e. /^\(.*\)\(\n\1\)\+$ --> highlight all double lines
but g/^\(.*\)\(\n\1\)\+$/d --> does NOT delete all double lines


Solution

  • Well, you can delete the searched pattern this way:

    :%s/<pattern>//gc
    

    And you can delete the whole line with the searched pattern this way:

    :g/<pattern>/d