Replicate a Vim function in Atom


I have always used a function in Vim that, when used at the beginning of a line, replaces certain characters with HTML entities. A shortened version is:

" Replace special typographic characters with entities
nnoremap ,r :call ReplaceChar()
function! ReplaceChar()
silent s/À/À/eg
silent s/Á/Á/eg
silent s/Â/Â/eg
silent s/Ã/Ã/eg
silent s/Ä/Ä/eg
silent s/Å/Å/eg
silent s/Æ/Æ/eg

Can anyone tell me how I could go about implementing this in Atom? I have tried the html-entities package, which is great, but gives some unexpected entities, for my use anyway. Thanks much!


Looks like the Atom package goes down to a Node package, and perhaps it’s possible to change the Atom package code to add a config variable, and then pass that down to the Node package to indicate that only these entities should be encoded.

Haven’t looked at the code closely. But it sounds like a meaningful starting point?


Thank you for pointing me in a direction … wasn’t sure how to proceed. Looking into it now, and found the files and arrays. The config variable is beyond me, but I might just try editing the existing package.


I figured out that the html-entities package is awesome! Thing is, it had been replacing my characters with html5 entities, which is a whole other world of entities. Managed to switch it to use html4 entities by editing a line in the package’s index.js file. Thanks again.