update to latest vim mode from cloud9
This commit is contained in:
parent
76cbc3f543
commit
7edd5724ef
4 changed files with 77 additions and 31 deletions
|
|
@ -20,11 +20,7 @@ var NUMBER = 1;
|
||||||
var OPERATOR = 2;
|
var OPERATOR = 2;
|
||||||
var MOTION = 3;
|
var MOTION = 3;
|
||||||
var ACTION = 4;
|
var ACTION = 4;
|
||||||
|
var HMARGIN = 8; // Minimum amount of line separation between margins;
|
||||||
//var NORMAL_MODE = 0;
|
|
||||||
//var INSERT_MODE = 1;
|
|
||||||
//var VISUAL_MODE = 2;
|
|
||||||
//getSelectionLead
|
|
||||||
|
|
||||||
exports.searchStore = {
|
exports.searchStore = {
|
||||||
current: "",
|
current: "",
|
||||||
|
|
@ -39,11 +35,34 @@ exports.searchStore = {
|
||||||
};
|
};
|
||||||
|
|
||||||
var repeat = function repeat(fn, count, args) {
|
var repeat = function repeat(fn, count, args) {
|
||||||
count = parseInt(count);
|
count = parseInt(count, 10);
|
||||||
while (0 < count--)
|
while (0 < count--)
|
||||||
fn.apply(this, args);
|
fn.apply(this, args);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var toggleCase = function toggleCase(ch) {
|
||||||
|
if (ch.toUpperCase() === ch)
|
||||||
|
return ch.toLowerCase();
|
||||||
|
else
|
||||||
|
return ch.toUpperCase();
|
||||||
|
};
|
||||||
|
|
||||||
|
var ensureScrollMargin = function(editor) {
|
||||||
|
setTimeout(function() {
|
||||||
|
var curPos = editor.getCursorPosition().row;
|
||||||
|
var topRow = editor.renderer.layerConfig.firstRow;
|
||||||
|
var linesToBottom = editor.renderer.layerConfig.lastRow - curPos;
|
||||||
|
var linesToTop = curPos - topRow;
|
||||||
|
|
||||||
|
if (linesToBottom >= 0 && linesToBottom < HMARGIN) {
|
||||||
|
editor.scrollToRow(topRow + (HMARGIN - linesToBottom));
|
||||||
|
}
|
||||||
|
else if (linesToTop >= 0 && linesToTop < HMARGIN) {
|
||||||
|
editor.scrollToRow(topRow - (HMARGIN - linesToTop));
|
||||||
|
}
|
||||||
|
}, 20); // Delay introduced to ensure scroll after async find operation.
|
||||||
|
};
|
||||||
|
|
||||||
var actions = {
|
var actions = {
|
||||||
"z": {
|
"z": {
|
||||||
param: true,
|
param: true,
|
||||||
|
|
@ -83,8 +102,9 @@ var actions = {
|
||||||
fn: function(editor, range, count, param) {
|
fn: function(editor, range, count, param) {
|
||||||
editor.selection.selectWord();
|
editor.selection.selectWord();
|
||||||
editor.findNext();
|
editor.findNext();
|
||||||
|
ensureScrollMargin(editor);
|
||||||
var cursor = editor.selection.getCursor();
|
var cursor = editor.selection.getCursor();
|
||||||
var range = editor.session.getWordRange(cursor.row, cursor.column);
|
range = editor.session.getWordRange(cursor.row, cursor.column);
|
||||||
editor.selection.setSelectionRange(range, true);
|
editor.selection.setSelectionRange(range, true);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -92,23 +112,32 @@ var actions = {
|
||||||
fn: function(editor, range, count, param) {
|
fn: function(editor, range, count, param) {
|
||||||
editor.selection.selectWord();
|
editor.selection.selectWord();
|
||||||
editor.findPrevious();
|
editor.findPrevious();
|
||||||
|
ensureScrollMargin(editor);
|
||||||
var cursor = editor.selection.getCursor();
|
var cursor = editor.selection.getCursor();
|
||||||
var range = editor.session.getWordRange(cursor.row, cursor.column);
|
range = editor.session.getWordRange(cursor.row, cursor.column);
|
||||||
editor.selection.setSelectionRange(range, true);
|
editor.selection.setSelectionRange(range, true);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"n": {
|
"n": {
|
||||||
fn: function(editor, range, count, param) {
|
fn: function(editor, range, count, param) {
|
||||||
editor.findNext(editor.getLastSearchOptions());
|
var options = editor.getLastSearchOptions();
|
||||||
|
options.backwards = false;
|
||||||
|
|
||||||
|
editor.findNext(options);
|
||||||
|
|
||||||
|
ensureScrollMargin(editor);
|
||||||
editor.selection.clearSelection();
|
editor.selection.clearSelection();
|
||||||
//editor.navigateWordLeft();
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"shift-n": {
|
"shift-n": {
|
||||||
fn: function(editor, range, count, param) {
|
fn: function(editor, range, count, param) {
|
||||||
editor.findPrevious(editor.getLastSearchOptions());
|
var options = editor.getLastSearchOptions();
|
||||||
|
options.backwards = true;
|
||||||
|
|
||||||
|
editor.navigateWordLeft();
|
||||||
|
editor.findPrevious(options);
|
||||||
|
ensureScrollMargin(editor);
|
||||||
editor.selection.clearSelection();
|
editor.selection.clearSelection();
|
||||||
//editor.navigateWordLeft();
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"v": {
|
"v": {
|
||||||
|
|
@ -231,8 +260,9 @@ var actions = {
|
||||||
},
|
},
|
||||||
".": {
|
".": {
|
||||||
fn: function(editor, range, count, param) {
|
fn: function(editor, range, count, param) {
|
||||||
var previous = inputBuffer.previous;
|
|
||||||
util.onInsertReplaySequence = inputBuffer.lastInsertCommands;
|
util.onInsertReplaySequence = inputBuffer.lastInsertCommands;
|
||||||
|
var previous = inputBuffer.previous;
|
||||||
|
if (previous) // If there is a previous action
|
||||||
inputBuffer.exec(editor, previous.action, previous.param);
|
inputBuffer.exec(editor, previous.action, previous.param);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -336,7 +366,7 @@ var inputBuffer = exports.inputBuffer = {
|
||||||
var o = action.operator;
|
var o = action.operator;
|
||||||
var a = action.action;
|
var a = action.action;
|
||||||
|
|
||||||
if(o) {
|
if (o) {
|
||||||
this.previous = {
|
this.previous = {
|
||||||
action: action,
|
action: action,
|
||||||
param: param
|
param: param
|
||||||
|
|
@ -489,12 +519,4 @@ var handleCursorMove = exports.onCursorMove = function(editor) {
|
||||||
handleCursorMove.running = false;
|
handleCursorMove.running = false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
function toggleCase(ch) {
|
|
||||||
if(ch.toUpperCase() === ch)
|
|
||||||
return ch.toLowerCase();
|
|
||||||
else
|
|
||||||
return ch.toUpperCase();
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
"never use strict"
|
"use strict"
|
||||||
|
|
||||||
define(function(require, exports, module) {
|
define(function(require, exports, module) {
|
||||||
|
|
||||||
|
|
@ -114,6 +114,30 @@ module.exports = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"shift-f": {
|
||||||
|
param: true,
|
||||||
|
nav: function(editor, range, count, param) {
|
||||||
|
count = parseInt(count, 10) || 1;
|
||||||
|
var ed = editor;
|
||||||
|
var cursor = ed.getCursorPosition();
|
||||||
|
var column = util.getLeftNthChar(editor, cursor, param, count);
|
||||||
|
|
||||||
|
if (typeof column === "number") {
|
||||||
|
ed.selection.clearSelection(); // Why does it select in the first place?
|
||||||
|
ed.moveCursorTo(cursor.row, cursor.column - column + 1);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
sel: function(editor, range, count, param) {
|
||||||
|
count = parseInt(count, 10) || 1;
|
||||||
|
var ed = editor;
|
||||||
|
var cursor = ed.getCursorPosition();
|
||||||
|
var column = util.getLeftNthChar(editor, cursor, param, count);
|
||||||
|
|
||||||
|
if (typeof column === "number") {
|
||||||
|
ed.moveCursorTo(cursor.row, cursor.column - column + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"t": {
|
"t": {
|
||||||
param: true,
|
param: true,
|
||||||
nav: function(editor, range, count, param) {
|
nav: function(editor, range, count, param) {
|
||||||
|
|
|
||||||
|
|
@ -88,9 +88,9 @@ module.exports = {
|
||||||
},
|
},
|
||||||
getLeftNthChar: function(editor, cursor, char, n) {
|
getLeftNthChar: function(editor, cursor, char, n) {
|
||||||
var line = editor.getSession().getLine(cursor.row);
|
var line = editor.getSession().getLine(cursor.row);
|
||||||
var matches = line.substr(0, cursor.column + 1).split(char);
|
var matches = line.substr(0, cursor.column).split(char);
|
||||||
|
|
||||||
return n < matches.length ? matches.slice(-1 * n).join(char).length + 1: 0;
|
return n < matches.length ? matches.slice(-1 * n).join(char).length + 2 : 0;
|
||||||
},
|
},
|
||||||
toRealChar: function(char) {
|
toRealChar: function(char) {
|
||||||
if (char.length === 1)
|
if (char.length === 1)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue