Automatic char replace


#1

In scala you can use ⇒ instead of =>. Is there a plugin that can replace this automatically as you type?


#2

something similar to this: https://github.com/blakegarretson/smart-quotes-plus


#3

Add this to your init script (File > Init Script)

Replaces on save.

atom.workspaceView.on 'core:save', ->
  editor = atom.workspace.getActiveEditor()
  return unless editor?.getGrammar()?.scopeName is 'source.scala'
  text = editor.getText()
  text = text.replace /(^|\s)(=>)(\s|$)/g, ($0) -> '⇒'
  editor.setText(text)

Not sure if there’s an editor:insert-text like event.


#4

thanks a lot. That’s a good start


#5

Sorry to bother you with something so trivial but I have no life. The line above is not needed. The next line with return will cover that case.