Key Bind Regex Find and Replace


#1

I’m trying to bind a find-and-replace query to a key so that the following is executed when a series of buttons is pressed:

Regex Find-and-replace: | with \n |

Does anyone have experience doing this sort of thing?


#2

No, but you can do it in your init.coffee file or better yet a package.


#3

Is what I’m trying to effect called something particular that would help with searching?

Is there a similar implementation that would be useful as a guide?


#4

It’s all in the API. Go there and look up “commands” and "texteditor and/or “textbuffer” commands. Doing a regex on the buffer is a supported API operation.


#5

You’re looking for the TextEditor.scan method for performing the search and replace function. And if you search for init.coffee here on Discuss, there are plenty of examples of creating commands in your init.coffee … this topic has a number of samples:


#6

Thanks – this will get me started!