Is there a way to select all lines that match a regular expression?


Say I want to select or delete all lines that had the word "debug" in it. How would I do that? Is there some way to get multiple cursors with a find?

Comment actions Permalink

It could have been useful to also directly mention "CTRL+ALT+SHIFT+J" (and/or the term "Select All Occurrences" to look up in the Keymap settings).

"RTFM" is something you expect to hear from peers, not from a vendor...

Comment actions Permalink

Hi Oz BE,


I can't find what I'm looking for in the documentation. I have the same question - how to actually select and then delete all *lines* with a term in them. For me I have a 1000s line long file that I'd like to reduce down by removing all lines starting with " 'EDGAR': ". I can easily find and replace and select all the instances of " 'EDGAR': " but how do I select and delete the *lines*?



Comment actions Permalink

Hi Martha,


1. Select the word "EDGAR" anywhere in the editor.

2. Press the combination: CTRL+ALT+SHIFT+J.

3. Now, all occurrences of "EDGAR" in the document should be selected, and each of them should have a caret.

4. Press HOME to bring all carets to the beginning of the line.

5. Press SHIFT+DELETE to delete them (i.e. it would delete all lines that have carets in them).


If you need this to be done only on lines that start with "EDGAR" and not on all lines that *contain* "EDGAR" then you need to make your initial selection a little more specific.

For example, if your lines are indented, then you can select the first word (i.e. "EDGAR") together with the indentation character(s). If they are not indented, then you can indent them (CTRL+A to select all, and TAB), follow the above procedure, and then unindent (CTRL+A, and then SHIFT+TAB).


I hope it helps :)


Comment actions Permalink

Actually worked it out just after posting! Putting it here for anyone else in the future with the same question:

(for mac)

- select phrase

- CMD + F (opens find menu)

- SHIFT + CMD + G (selects all occurences)

- CMD + DELETE (deletes the whole line where the curser is, in this case deletes all lines with the phrase in)

Also thanks Oz BE for beating me by 2 minutes with the answer for windows! :)

Comment actions Permalink


This was super helpful and [almost] exactly what I was looking for. Thank you! (I was actually searching for a way to do this less manually and/or for all occurrences in the project, not just one file, however I wouldn't be surprised if that's just simply not possible. This still saved me a ton of time.)

One point though, I believe your step 4 should be HOME (edited), not CTRL+HOME.

And for anyone else, I did find the documentation for this feature,

Thanks again!

Comment actions Permalink

Hi Alex R.,


I'm glad it helped!

You're right about the CTRL+HOME, it was a mistake. I think I meant to write something like "double home", but actually a single HOME is enough, so I updated my comment.




Please sign in to leave a comment.