Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delete all lines that don't contain a string in Sublime Text

Tags:

sublimetext3

So I have around 1000 lines of a text document and was wondering if it's possible to delete all lines on Sublime Text that don't contain a certain keyword, in my case: @

like image 335
Okym Avatar asked Nov 30 '22 08:11

Okym


1 Answers

(Edited) Steps

To delete all of the lines NOT containing occurrences of the keyword, use the following:

Mac

  • Select your keyword (via double click, drag, etc, say @ in your case)
  • Command + Ctrl + G to select all occurrences
  • Hold Command and press Left Arrow
  • Hold Shift and Command and press Right Arrow
  • Cut with Command + X
  • Select All with Command + A
  • Backspace to delete all file contents
  • Paste with Command + V

Windows

  • Select your keyword (say @ in your case)
  • Alt + F3 to select all occurrences
  • Hold Control and press Home
  • Hold Shift and press End
  • Cut with Ctrl + X
  • Select All with Ctrl + A
  • Backspace to delete all file contents
  • Paste with Ctrl + V
like image 177
Matt Goodrich Avatar answered Dec 09 '22 08:12

Matt Goodrich