Delete line containing string (equivalent of Notepad++ "delete bookmarked lines")


I want to delete lines that contain a string.

I’m coming from Notepad++ where I can do a regex (and more importantly (since I’m not a regex guru), a non-regex) search in a file, bookmark all the lines containing my search, and then delete either the bookmarked files or the non-booked marked files.

Is there a way to do this easily in atom?


did you get the answer to your prob. I caught on the same issue :frowning:


With the regular expression mode on in the find-and-replace panel you can search for ^.*test.*\n where “test” is the text you want to search for and replace it with nothing.


Thanks leedohm for your reply. I am actually looking for a feature to bookmarked all lines containing the word “test”.
I could then copy all the marked lines (== in other words copy all lines containing “test”). Actually I work on Cisco router configuration file where output is large file with repetitive text with different values. and I am only interested to fetch certain lines lets say all line contain “ip address” for a list of all IP address configured on the router.

Actually this is a tremendous feature from notepad++ which i am deeply missing after moving to atom.


Are you open to changing your workflow slightly? Or will you only accept answers that work exactly like Notepad++? The reason why I ask is that Atom uses multiple cursors to support the type of scenarios you seem to be asking about … whereas it appears that Notepad++ uses bookmarks.

I completely understand wanting to just get things done in a comfortable way. There is always a cost to learning new ways of doing things. I just want to understand what exactly it is you need before offering a bunch of answers that don’t give you what you want.


Thanks that you understand my scenario. I am open to learn if atom gets it done for me by another mean ;).


Here is the full scenarion

interface FastEthernet2
no ip address
interface FastEthernet3
no ip address
interface FastEthernet4
no ip address
interface FastEthernet5
no ip address

I need to copy all the lines with having “ip address” and paste looks like following file

> no ip address
> no ip address
> no ip address
> no ip address


Here’s how I would do it:

  1. Open the Find dialog with Cmd+F on OS X or Ctrl+F on other platforms
  2. Enter my search text
  3. Let the search find all occurrences
  4. Select all occurrences using Ctrl+Cmd+G on OS X or Alt+F3 on other platforms
  5. Select all lines containing the text using Cmd+L on OS X or Ctrl+L on other platforms
  6. Copy all lines containing the text using Cmd+C on OS X or Ctrl+C on other platforms

Done :grinning:

Ah, you added an extra wrinkle of adding the > at the beginning of the pasted lines, but that’s easy too.

  1. Open a new file Cmd+N on OS X or Ctrl+N on other platforms
  2. Paste the text with Cmd+V on OS X or Ctrl+V on other platforms
  3. Go to the beginning of the lines using Cmd+← on OS X or Home on other platforms
  4. Enter the text: "> "

Really done :laughing:


great is there any way to remove empty lines in between

no ip address

no ip address

no ip address

no ip address


You should be able to go to the end of the line (with the multiple cursors still active) and press Delete to get rid of the empty lines.


Ok i get it to work Thanks a lot… but somehow the edoitor becomes unresponsive for a while and see below


Cool. I didn’t know about this. Is this a find/replace function or global?


It looks like every single individual character is selected. If that is the case it’s no surprise it is choking. Is there a way to select lines instead of chars?

P.S. Did it finish after clicking on “Keep Waiting”?


yes iI get response in couple of minutes wait… after i click keep waiting


Coffee break time. (JK)


Looks like someone created a package that does this:


I was using the delete-lines package until I needed to use regular expressions with it, and it didn’t work.
Trying to find a solution I bumped into this discussion (which I think was also the one where I found about the delete-lines package).

I was trying the above example and trick to select lines and It just doesn’t work in the “Select all” / Alt-F3 part.

So I do an CTRL-F and write “no ip.*” which finds me the string until the end of the line I then try to select all by using ALT-F3 and nothing happens or I try CTRL-SHIFT-P and search directly for the option find-and-replace:select-all but it doesn’t find it.

Am I missing something or as something changed in the editor (versions 1.13.1 and 1.14)?


If you’re talking about the example above where you want to delete the empty lines between all the no ip entries, the way that I would do it is this:

  1. Open Find and Replace using Cmd+F on macOS or Ctrl+F on other platforms
  2. Ensure that Regular Expressions mode is enabled by checking the .* button in the upper right of the Find and Replace panel
  3. Enter ^\n in the Find box
  4. Enter nothing in the Replace box
  5. Click “Find All” if nothing is highlighted
  6. Click “Replace All”


Actually I was trying the other example. But it doesn’t matter, what I wanted was to test the functionality you were talking about above.

And thanks to your last post, I found out what my mistake was.
I was doing ALT-F3 (find-and-replace:select-all) to try to select the text instead of ALT-ENTER (Find All).

After you “Find All” you can just copy the text to a new file and skip selecting the lines with CTRL-L (which also copies the extra new line).