Is there a way to either record or script a search & replace sequence?


#1

I would be able to automate a search & replace sequence, I have a few cases for this – eliminate multiple new lines or spaces in CSS or HTML or replace some special characters / w diacritics.
One would’ve achieved that in ST with RegReplace.


#2

I don’t know if there is a package for this kind of thing already, but there is plenty of API support for it. You could either write a package or just use the init.coffee to create custom commands for the kind of thing you want.


#3

If I would’ve been capable of writing my own package I might not have asked the question in the first place :confused:


#4

+1
BUMP


#5

@ldexterldesign Atom’s APIs allow this to be implemented in a package if anyone wants to give it a try.


#6

:grinning: https://atom.io/packages/atom-keyboard-macros

Hope this is useful

Regards


#7

atom-keyboard-macros does not even install for me.
is there at least a way to have a history of search and replace? Other text editors keep a cache in drop downs.


#8

Yea, I’ve kinda given up on this

https://github.com/JunSuzukiJapan/atom-keyboard-macros/issues/32 - been waiting for a response for some basic features for a while now

Regards


#9

I found html-special-character-replacer and swapped the default list with my own list. Most of the stuff that I wanted to replace was special characters, but I do not need the huge list provided. Big thanks for the person that developed this package: BRiL1201. I think he can rebrand it as a search and replace tool, and provide instructions how to customize it. It would be nice if it had an option to choose between js files. This is a start for me. Manually, someone could start Atom with different js files if more than one is needed.

C:\Users\windowsusername.atom\packages\html-special-character-replacer\lib\html-special-character-replacer.js

function doreplacement(text)
{

text = text.replace(/“/g,'“');
text = text.replace(/”/g,'”');
text = text.replace(/…/g,'…');
text = text.replace(/–/g,'–');
text = text.replace(/—/g,'—');

return text;

};