Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio Code - Removing Lines Containing criteria

This probably isn't a VS Code-specific question but it's my tool of choice.

I have a log file with a lot of lines containing the following:

Company.Environment.Security.RightsBased.Policies.RightsUserAuthorizationPolicy

Those are debug-level log records that clutter the file I'm trying to process. I'm looking to remove the lines with that content.

I've looked into Regex but, unlike removing a blank line where you have the whole content in the search criteria (making find/replace easy), here I need to match from line break to line break on some criteria between the two, I think...

What are your thoughts on how criteria like that would work?

like image 831
Killnine Avatar asked Jul 31 '18 16:07

Killnine


People also ask

How do you delete lines with certain keywords in VS Code?

Ctrl + Shift + K for delete line. You can also fire the replace with an empty field, instead of using a keyboard combination. It works fine also.


1 Answers

If the criteria is a particular string and you don't want to have to remember regexes, there is a few handy keyboard shortcuts that can help you out. I'm going to assume you're on a Mac.

  1. Cmd-F to open find.
  2. Paste your string.
  3. Alt-Enter to select all of the instances of the string on the page.
  4. Cmd-L to broaden the selection to the entire line of each instance on the page.
  5. Delete/Backspace to remove those lines.
like image 80
James Avatar answered Sep 18 '22 15:09

James