summaryrefslogtreecommitdiff
path: root/public/vendor/codemirror/keymap/vim.js
diff options
context:
space:
mode:
Diffstat (limited to 'public/vendor/codemirror/keymap/vim.js')
-rw-r--r--public/vendor/codemirror/keymap/vim.js24
1 files changed, 15 insertions, 9 deletions
diff --git a/public/vendor/codemirror/keymap/vim.js b/public/vendor/codemirror/keymap/vim.js
index 4278ee97..afed132e 100644
--- a/public/vendor/codemirror/keymap/vim.js
+++ b/public/vendor/codemirror/keymap/vim.js
@@ -72,6 +72,7 @@
{ keys: '<PageUp>', type: 'keyToKey', toKeys: '<C-b>' },
{ keys: '<PageDown>', type: 'keyToKey', toKeys: '<C-f>' },
{ keys: '<CR>', type: 'keyToKey', toKeys: 'j^', context: 'normal' },
+ { keys: '<Ins>', type: 'action', action: 'toggleOverwrite', context: 'insert' },
// Motions
{ keys: 'H', type: 'motion', motion: 'moveToTopLine', motionArgs: { linewise: true, toJumplist: true }},
{ keys: 'M', type: 'motion', motion: 'moveToMiddleLine', motionArgs: { linewise: true, toJumplist: true }},
@@ -276,6 +277,7 @@
function cmKey(key, cm) {
if (!cm) { return undefined; }
+ if (this[key]) { return this[key]; }
var vimKey = cmKeyToVimKey(key);
if (!vimKey) {
return false;
@@ -288,7 +290,7 @@
}
var modifiers = {'Shift': 'S', 'Ctrl': 'C', 'Alt': 'A', 'Cmd': 'D', 'Mod': 'A'};
- var specialKeys = {Enter:'CR',Backspace:'BS',Delete:'Del'};
+ var specialKeys = {Enter:'CR',Backspace:'BS',Delete:'Del',Insert:'Ins'};
function cmKeyToVimKey(key) {
if (key.charAt(0) == '\'') {
// Keypress character binding of format "'a'"
@@ -2174,6 +2176,17 @@
var registerName = actionArgs.selectedCharacter;
macroModeState.enterMacroRecordMode(cm, registerName);
},
+ toggleOverwrite: function(cm) {
+ if (!cm.state.overwrite) {
+ cm.toggleOverwrite(true);
+ cm.setOption('keyMap', 'vim-replace');
+ CodeMirror.signal(cm, "vim-mode-change", {mode: "replace"});
+ } else {
+ cm.toggleOverwrite(false);
+ cm.setOption('keyMap', 'vim-insert');
+ CodeMirror.signal(cm, "vim-mode-change", {mode: "insert"});
+ }
+ },
enterInsertMode: function(cm, actionArgs, vim) {
if (cm.getOption('readOnly')) { return; }
vim.insertMode = true;
@@ -2219,7 +2232,6 @@
return;
}
}
- cm.setOption('keyMap', 'vim-insert');
cm.setOption('disableInput', false);
if (actionArgs && actionArgs.replace) {
// Handle Replace-mode as a special case of insert mode.
@@ -2227,6 +2239,7 @@
cm.setOption('keyMap', 'vim-replace');
CodeMirror.signal(cm, "vim-mode-change", {mode: "replace"});
} else {
+ cm.toggleOverwrite(false);
cm.setOption('keyMap', 'vim-insert');
CodeMirror.signal(cm, "vim-mode-change", {mode: "insert"});
}
@@ -4771,13 +4784,6 @@
CodeMirror.keyMap['vim-insert'] = {
// TODO: override navigation keys so that Esc will cancel automatic
// indentation from o, O, i_<CR>
- 'Ctrl-N': 'autocomplete',
- 'Ctrl-P': 'autocomplete',
- 'Enter': function(cm) {
- var fn = CodeMirror.commands.newlineAndIndentContinueComment ||
- CodeMirror.commands.newlineAndIndent;
- fn(cm);
- },
fallthrough: ['default'],
attach: attachVimMap,
detach: detachVimMap,