Merge pull request #381 from kemayo/master
Improve VIM key bindings a bit
This commit is contained in:
commit
0bc16ea45d
1 changed files with 26 additions and 68 deletions
|
|
@ -40,6 +40,22 @@ define(function(require, exports, module) {
|
||||||
var StateHandler = require("ace/keyboard/state_handler").StateHandler;
|
var StateHandler = require("ace/keyboard/state_handler").StateHandler;
|
||||||
var matchCharacterOnly = require("ace/keyboard/state_handler").matchCharacterOnly;
|
var matchCharacterOnly = require("ace/keyboard/state_handler").matchCharacterOnly;
|
||||||
|
|
||||||
|
var vimcommand = function(key, exec, then) {
|
||||||
|
return {
|
||||||
|
regex: [ "([0-9]*)", key ],
|
||||||
|
exec: exec,
|
||||||
|
params: [
|
||||||
|
{
|
||||||
|
name: "times",
|
||||||
|
match: 1,
|
||||||
|
type: "number",
|
||||||
|
defaultValue: 1
|
||||||
|
}
|
||||||
|
],
|
||||||
|
then: then
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var vimStates = {
|
var vimStates = {
|
||||||
start: [
|
start: [
|
||||||
{
|
{
|
||||||
|
|
@ -75,78 +91,20 @@ var vimStates = {
|
||||||
exec: "overwrite",
|
exec: "overwrite",
|
||||||
then: "replaceMode"
|
then: "replaceMode"
|
||||||
},
|
},
|
||||||
{
|
vimcommand("(k|up)", "golineup"),
|
||||||
regex: [ "([0-9]*)", "(k|up)" ],
|
vimcommand("(j|down)", "golinedown"),
|
||||||
exec: "golineup",
|
vimcommand("(l|right)", "golineright"),
|
||||||
params: [
|
vimcommand("(h|left)", "golineleft"),
|
||||||
{
|
|
||||||
name: "times",
|
|
||||||
match: 1,
|
|
||||||
type: "number",
|
|
||||||
defaultValue: 1
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
regex: [ "([0-9]*)", "(j|down|enter)" ],
|
|
||||||
exec: "golinedown",
|
|
||||||
params: [
|
|
||||||
{
|
|
||||||
name: "times",
|
|
||||||
match: 1,
|
|
||||||
type: "number",
|
|
||||||
defaultValue: 1
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
regex: [ "([0-9]*)", "(l|right)" ],
|
|
||||||
exec: "gotoright",
|
|
||||||
params: [
|
|
||||||
{
|
|
||||||
name: "times",
|
|
||||||
match: 1,
|
|
||||||
type: "number",
|
|
||||||
defaultValue: 1
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
regex: [ "([0-9]*)", "(h|left)" ],
|
|
||||||
exec: "gotoleft",
|
|
||||||
params: [
|
|
||||||
{
|
|
||||||
name: "times",
|
|
||||||
match: 1,
|
|
||||||
type: "number",
|
|
||||||
defaultValue: 1
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
key: "shift-g",
|
key: "shift-g",
|
||||||
exec: "gotoend"
|
exec: "gotoend"
|
||||||
},
|
},
|
||||||
{
|
vimcommand("b", "gotowordleft"),
|
||||||
key: "b",
|
vimcommand("e", "gotowordright"),
|
||||||
exec: "gotowordleft"
|
vimcommand("x", "del"),
|
||||||
},
|
vimcommand("shift-x", "backspace"),
|
||||||
{
|
vimcommand("shift-d", "removetolineend"),
|
||||||
key: "e",
|
vimcommand("u", "undo"), // [count] on this may/may not work, depending on browser implementation...
|
||||||
exec: "gotowordright"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: "x",
|
|
||||||
exec: "del"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: "shift-x",
|
|
||||||
exec: "backspace"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: "shift-d",
|
|
||||||
exec: "removetolineend"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
comment: "Catch some keyboard input to stop it here",
|
comment: "Catch some keyboard input to stop it here",
|
||||||
match: matchCharacterOnly
|
match: matchCharacterOnly
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue