#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

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