Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Atom.io search and delete, is it possible?

Tags:

atom-editor

Has anyone figured out a way to use Atom.io's awesome search feature to find and delete lines? For example, I want to remove all lines that match ^\s*color: #3f3f3f;$from my css.

I don't want to leave empty lines.

like image 937
linuxdan Avatar asked Jan 26 '16 17:01

linuxdan


People also ask

How do I search in atom io?

To search within your current file you can press Ctrl+F , type in a search string and press Enter (or F3 or the "Find Next" button) multiple times to cycle through all the matches in that file. Alt+Enter will find all occurences of the search string.

How do you undo something in an Atom?

When in a file that needs reverting, press ctrl-cmd-r to revert the file.

How do I delete a line in Atom editor?

Delete Whitelines is an Atom package for removing empty lines. Just Select the text, use command palette (cmd + shift + P) > delete-whitelines:toggle or alt+shift+D (for MAC & windows) to remove empty lines within the selected text area.


3 Answers

Because $ doesn't match newline or carriage return I needed to be more explicit. The pattern \n?\r? seemed to do the trick for me.

My final regex is:

^\s*color: #3f3f3f;\n?\r?

It might need to be modified depending on your line endings. I think ^\s*color: #3f3f3f;\n?\r?\n? should be pretty universal.

like image 119
linuxdan Avatar answered Oct 11 '22 00:10

linuxdan


You can simply replace that match with an empty string - ie, leave the Replace in current buffer field empty, and do a Replace.

You have to take care of matching the whole line so you don't end up with an empty line.

like image 26
mgarciaisaia Avatar answered Oct 11 '22 02:10

mgarciaisaia


I just tested it and if you simply leave the replace field empty, then click replace, it will delete.

like image 2
mjones Avatar answered Oct 11 '22 02:10

mjones