3 ms·
> As for motions, what kind of motions do you think are difficult to create? It's mostly text objects. Text objects for scope, variable references, etc. I thin
by grayrest 14y ago
> As for motions, what kind of motions do you think are difficult to create?
It's mostly text objects. Text objects for scope, variable references, etc. I think there are motions I have not yet discovered that operate on syntax trees. These are nonlinear the way surround is nonlinear.
I was introduced to multiple selection and generalized cursors when one of the DabbleDB guys implemented a generalized cursor editor. I thought it was awesome and did a bunch of research:
http://static.usenix.org/events/usenix01/full_papers/miller/miller_html/ http://static.usenix.org/events/usenix01/full_papers/miller/...
http://scholar.google.com/scholar?q=related:7040sK6UgeAJ:scholar.google.com/&hl=en&as_sdt=0,33 http://scholar.google.com/scholar?q=related:7040sK6UgeAJ:sch...
After reading a bunch, I got around to thinking what I'd have to do to implement an editor that could handle generalized cursors based on my experience with vim and hacking on it.
I came up with the idea for an edit core consisting of motions as compositions of partially applied functions. Takes a position returns a list of ranges, applying the list of ranges to an operator produces an edit. The jump from there to regions is pretty straightforward. The system also provides a clear path to how keyboard mapping would work (along with stealing the context ideas from ST).
I'm unaware of an editor that works this way but I find it difficult to believe I'm the first person to think of this. If I can successfully maneuver my job into building web development tools, I expect to gut Codemirror and replace the core operations with these primitives as a top priority but I haven't gotten there yet.
For context sensitive stuff: You can do clever stuff with it. As an example, if you're in a JSON file, after an identifier, and you type a : the editor can automatically put quotes around the key if it's not already quoted. My intro to the usefulness of context sensitive keys was that the ruby textmate bundle would insert Ruby interpolation (#{|} with | for cursor) when you hit # in a string.
- goldfeld 14y agoCan you not do most context sensitive stuff by running regexes on current and neighboring lines? That all sounds terrific, and if you get to implement these ideas on top of web technologies (or anywhere else would still be half as good) I'd love to hear about and possibly contribute. Do you have a blog or twitter or app.net I can follow?
- grayrest 14y agoYou can get pretty far with regexes but you run into non hygenic macro problems. I use UltiSnips with regex snippets and python replacements and have gotten interesting stuff out of it like the JSON key quoting. The problem is that I have to remember to expand the snippet. It's the difference between having the always right indentation settings versus having the 90% right indentation settings. It doesn't seem like a lot of effort but results in a significant drop of cognitive load for me. I'm on twitter and use the same username everywhere.