#1151 initial support for marks

This commit is contained in:
nightwing 2012-12-15 17:37:15 +04:00
commit 91788f3424
2 changed files with 44 additions and 5 deletions

View file

@ -133,6 +133,18 @@ var actions = exports.actions = {
editor.selection.setSelectionRange(r, true); editor.selection.setSelectionRange(r, true);
} }
}, },
"m": {
param: true,
fn: function(editor, range, count, param) {
var s = editor.session;
var markers = s.vimMarkers || (s.vimMarkers = {});
var c = editor.getCursorPosition();
if (!markers[param]) {
markers[param] = editor.session.doc.createAnchor(c);
}
markers[param].setPosition(c.row, c.column, true);
}
},
"n": { "n": {
fn: function(editor, range, count, param) { fn: function(editor, range, count, param) {
var options = editor.getLastSearchOptions(); var options = editor.getLastSearchOptions();

View file

@ -583,7 +583,34 @@ module.exports = {
sel: function(editor, range, count, param) { sel: function(editor, range, count, param) {
keepScrollPosition(editor, editor.selectPageUp); keepScrollPosition(editor, editor.selectPageUp);
} }
} },
"`": new Motion({
param: true,
handlesCount: true,
getPos: function(editor, range, count, param, isSel) {
var s = editor.session;
var marker = s.vimMarkers && s.vimMarkers[param];
if (marker) {
return marker.getPosition();
}
}
}),
"'": new Motion({
param: true,
handlesCount: true,
getPos: function(editor, range, count, param, isSel) {
var s = editor.session;
var marker = s.vimMarkers && s.vimMarkers[param];
if (marker) {
var pos = marker.getPosition();
var line = editor.session.getLine(pos.row);
pos.column = line.search(/\S/);
if (pos.column == -1)
pos.column = line.length;
return pos;
}
}
}),
}; };
module.exports.backspace = module.exports.left = module.exports.h; module.exports.backspace = module.exports.left = module.exports.h;