Emacs like token-substitutions?

There’s a really neat feature in emacs where you can replace regex matches with arbitrary tokens.

For example, in JavaScript, you could replace any occurance of function with an italic f. It is only displayed as an f though, it’s still being saved as function.

Here’s a video showcasing the feature:

Is there a way to do this in Atom?


I’ve found a way to do the display part, but it completely messes up the editor’s lines of code. If I set my cursor at var sum = fn (a|rr) { (| being the cursor), then pressing backspace removes the invisible u in fUnction :frowning:. Of course, this also interferes with inserting etc…

1 Like

I just don’t think that Atom is ready for this kind of thing. Perhaps when support for proportionally-spaced fonts and other horizontally-differing structures is added can this be worked out.

Thought so, I was mildly impressed by that I could even get the display part working though. That’s more than what I could achieve with Sublime :confused:

1 Like

True. I’m impressed you got so far as well. Perhaps if you dug in to how the rendering of individual lines happens you can give some suggestions on how such things could be factored in so that when the Atom team gets around to rethinking these things, they can refer to your notes?

I’ll take a look at it, could be interesting.

This really look like some kind of folding to me, isn’t there something to do around that? (maybe the API will have to change to support it)

It does kind of look like folding, but folding can be turned on or off for each folding opportunity. If I’m understanding the proposal correctly, it is always on once the rule is put in place.

I was thinking that maybe the folding feature could be built upon a more generic code substitution feature that could also benefit this specific use case (and probably some other I can’t think of)

Yeah, that is a good idea. That might get rid of the complaints how the folding is formatted as well.

Wouldn’t it just be horizontal folding instead of vertical? You could solve the always on problem by unfolding if the cursor is placed within the region of the substitution.

Has there been any development on this issue in the past few years? Would love to use this feature for Clojure development :slight_smile:


This appears to be the only page on subject. Is this feature no longer popular, or maybe there’s a hidden package that I am not aware of?