Sublime Forum

Work with lines

#1

Hello everyone!

I have file with large list of phrases with keywords. Each phrase is on a separate line. I need to cut all lines that contains phrases with specific keyword and paste them into another empty file. Thus I want to group all the phrases by keywords.

Tell me please can Sublime Text find all lines that contain speific word or phrase and then cut them and paste into mpty file?

Thanks a lot in advance

0 Likes

#2

Easy with the ‘Find all’ option of the ‘Find’ feature (with regexp enabled).

If, for example, you want all lines with ‘disable’, search for ‘^.disable.$’, and then press ‘Find all’, copy and finally past in a new document.

0 Likes

#4

Thanks a lot!

Сan you tell me how to create a regular expression for the search lines with specific keyword if this keyword can be in different places of lines? For example I need to cut lines with keyword “mac” and lines containing this keyword look like this:

  • buy mac

  • mac os mojave

  • buy used mac alibaba

The regular expression that you wrote does not find such lines

0 Likes

#5

Personally, I do such things with multiple crtl+d (or alternatively with ‘select all’) on selected “mac” and then to crtl+k (delete line) remove all matched lines (or do smth different). Maybe this helps you on some cases.

0 Likes

#6

Hello!

At the end I found out how to to this!

  • Switch on the use of regular expressions
  • In search line write expressions: .*{search word}.*
  • Press “Find All” button
  • Copy results
  • Paste them into new page

That’s all! It’s awesome! Hope, it will be useful for forum visitors.

0 Likes