#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);
}
},
"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": {
fn: function(editor, range, count, param) {
var options = editor.getLastSearchOptions();

View file

@ -3,7 +3,7 @@
*
* Copyright (c) 2010, Ajax.org B.V.
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
@ -14,7 +14,7 @@
* * Neither the name of Ajax.org B.V. nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
@ -386,7 +386,7 @@ module.exports = {
var column = util.getRightNthChar(editor, cursor, param, count || 1);
if (typeof column === "number") {
cursor.column += column + (isSel ? 2 : 1);
cursor.column += column + (isSel ? 2 : 1);
return cursor;
}
}
@ -563,7 +563,7 @@ module.exports = {
while(row < l && !/\S/.test(session.getLine(row)))
row++;
while(/\S/.test(session.getLine(row)))
row++;
row++;
return {column: 0, row: row};
}),
"ctrl-d": {
@ -583,7 +583,34 @@ module.exports = {
sel: function(editor, range, count, param) {
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;