I’m trying to get a custom command into init.coffee
to run multiple regex replaces consequently. Here is what I’m trying:
atom.commands.add 'atom-text-editor', 'custom:process-report', ->
editor = atom.workspace.getActiveTextEditor()
regs=[]
res=[]
regs[0] = /""(?!;)/g
res[0]="'" # double quotes to single
regs[1] = /;"([A-Z])/g
res[1]=";$1" # quoted descriptions
for (i=0,len=regs.length;i<len;i++){
editor.scan(regs[i], (match) -> match.replace(res[i]))
}
Upon loading I get
Failed to load C:\Users\Vitaly.Sokolov\.atom\init.coffee
unexpected (
Syntax is more or less taken from the CoffeeScript documentation. What am I doing wrong? Are loops not supported in the init.coffee
? How do I do it properly then? I have about 7 regex to implement and I don’t want to hard-code variables for them.