marijnh/CodeMirror — pull request #1235 by metatheos (2013-02-11 20:49:25+00:00)
Title: A few changes to vim keymap

Changes
-------

1. :{number} brings you to the line with {number} on the gutter
2. :noh[lsearch] defined, replacing the `clearSearchHighlight`-action. ",/" doesn't work out of the box anymore, but can be recreated through `CodeMirror.Vim.map(',/',':noh')`. Also changed the test for this (it didn't test clearing selection before, as far as I can tell).
3. Changed `parseKeyString` so it now not only Accepts \ but <{Key}> as well. As a result things like `CodeMirror.Vim.map(',',':noh');` work now.
4. Added `CodeMirror.Vim.defineEx(name:string,prefix:string,func:function)` api. Notes below.
5. Added gj and gk, mapped to new `moveByDisplayLines`. Instead of moving to `cm.getCursor().ch` on a neighboring line, these commands behave more like `moveV()`, staying in the same column. This allows to move vertically within wrapped lines. Can override the default j/k-behavior through `CodeMirror.Vim.map('j','gj');` and `CodeMirror.Vim.map('k','gk');`.

Notes on defineEx
-----------------

* name/prefix should obviously be unique, since they are used as identifier for the command.
* "prefix" must be an actual prefix of "name", so "writeall" as name cannot be registered with prefix "wa", while "wall" works as name.
* When selecting a command, the command with the longest matching prefix and matching full name is used (no changes to existing behavior here).

Example usage for defineEx
--------------------------

//the following code registers :hello[world]
CodeMirror.Vim.defineEx('helloworld','hello',function(cm,params){
console.log("Hello world")
if(params.args)for(var i=0; i