marijnh/CodeMirror — pull request #1091 by mightyguava (2012-12-15 23:06:14+00:00)
Title: [vim keymap] Implement substitute

Lots of improvements here, but in summary, implements `:%s` and much more. Tested on `v2`, should be fully compatible with `v3`.

- Implement :substitute according to behavior below.
- [count] is not implemented
- Only `i` regex flag is supported
- Implement ranges in Ex commands
- This means `:%s` will work, so will `:5,10s`
- Implement visual mode marks `'<` and `'>`
- Add option to set default value in `dialog.js`
- If vim is in visual mode, default value is set to `'<,'>` to make Ex commands operate only on the selected range (i.e. `:'<,'>s/foo/bar/` will replace only the current selection).

```
:[range]s[ubstitute]/{pattern}/{string}/[flags] [count]
For each line in [range] replace a match of {pattern}
with {string}.
For the {pattern} see |pattern|.
{string} can be a literal string, or something
special; see |sub-replace-special|.
When [range] and [count] are omitted, replace in the
current line only.
When [count] is given, replace in [count] lines,
starting with the last line in [range]. When [range]
is omitted start in the current line.
Also see |cmdline-ranges|.
See |:s_flags| for [flags].
```