marijnh/CodeMirror — pull request #2327 by jasonsanjose (2014-03-03 23:48:13+00:00)
Title: [addon] Linked Mode

Coming from Eclipse (a long, long time ago), I really missed a feature they called linked mode. Actually, it even appears that Eclipse's Orion also implements a similar linked mode http://planetorion.org/news/2013/04/orion-3-0-m1-new-and-noteworthy. I don't know if this has been open sourced though.

Anyway...for those that haven't used something similar, typically it's used when dropping in a code template. Something as small as a code hint for a method call (e.g. `foo.doSomething(bar)`) or a longer HTML snippet (e.g.

...some snippet code...

). Here's a small HTML example with some markup to show :

<[span] id="[]">[content][]

Some high level concepts:

* Each group in square braces can be navigated using the TAB key
* Linked groups like the two ranges for "span" will mirror edits (e.g. typing "div" in the start tag will mirror the edits in the end tag)
* The last group is the exit position. When a user is done with input, they press ENTER to move their cursor outside of the template tag and continue editing the next piece of code.
* Pressing ESC will cancel linked mode and keep the cursor position unchanged
* Typing outside of the defined ranges will cancel linked mode immediately