Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Select all found RegEx results in Atom

Tags:

atom-editor

I'm trying to select all of the results found by a regex find so I can modify them all (not replace them with text!), for example, making them all uppercase with Cmd + K -> Cmd + U. I'm aware that I could do them one by one via repeating Cmd + G, Cmd + K, Cmd + U, but for a large file this simply isn't practical or realistic. I'm also aware of using bash and may other scripting alternatives, I'd like to find a way to do it inside Atom, I'm happy to install an external library if needed.

Example of selection

Things I've tried:

  1. Cmd + D, this just selects the next instance of that exact letter, not the next result matching the regex.
  2. Cmd + Shift + G and alternatives (alt/right shift/ctrl), Cmd + G selects the next result matching the Regex, which is in the right direction.
  3. Changing all of the selected text to a unique string, highlighting them all, pressing Cmd + Z and hoping it will stay selected, it doesn't.
  4. Lots of Googling and reading though Atom discussions.
  5. Reading Atom's documentation on the subject
like image 439
Aaron Critchley Avatar asked Sep 10 '15 16:09

Aaron Critchley


People also ask

How do you select all occurrences of a word in an atom?

You can select several occurrences of the same word using ctrl + d repeatedly, or select all the occurrences by typing alt + F3 .

How do you find and replace all atoms?

You can also find and replace throughout your entire project if you invoke the panel with Ctrl+Shift+F .

Does Atom support regex?

This takes advantage of a built in regex feature in the Atom text editor. It may work in other text editors as well, so give it a try in your favorite text editor or IDE.


2 Answers

Pressing Alt + Enter will select all instances matching your Find results. This works for RegEx search also.

Source: https://github.com/atom/find-and-replace/pull/290

like image 87
Johno Avatar answered Sep 26 '22 13:09

Johno


On Atom 1.57 (nov 2021) clicking on "find all" selects all matching items, esc to exit the search box, then copy :)

enter image description here

Alternatively you can select all whit the menu -> find > select all.

On mac also selects all by pressing ^ + cmd + G.

like image 29
NicoKowe Avatar answered Sep 23 '22 13:09

NicoKowe