CodeMirror: Range Collapsing Demo

Click on the right side of the gutter, then click again below, the code between will collapse. Click on either arrow to expand. To use, simply include the collapserange.js file and set collapseRange: true in options.