Replace All predefined regex values - shortcut


#1

Hi, i can’t find if is it possible to make shortcut which would replace all values A (A is regex) to B (B is fixed).

Thanks in advance :slight_smile:


#2

You can use regular expressions in Find and Replace. If you want to do it via a command, there’s a scan() method in the TextEditor object that can do the same. If you’re doing major adjustments (it doesn’t sound like you are), you can use TextBuffer's getText() to extract all the text as a string, edit the string, and then replace it with setText().


#3

Thank for the answer. But still I have some problems to do it:
'atom-text-editor': 'ctrl-shift-m': scan("a", replace("b"))
is not working. How should i build those functions?


#4

You have to define a command, either in a package or in your init.coffee.

Why isn’t the normal Find and Replace functionality sufficient?