Skip to content

Instantly share code, notes, and snippets.

Created April 11, 2010 20:50
Show Gist options
  • Save anonymous/363051 to your computer and use it in GitHub Desktop.
Save anonymous/363051 to your computer and use it in GitHub Desktop.
diff -r 13a375950d95 plugins/supported/text_editor/commands/editing.js
--- a/plugins/supported/text_editor/commands/editing.js Fri Apr 09 14:57:19 2010 -0400
+++ b/plugins/supported/text_editor/commands/editing.js Sun Apr 11 16:38:46 2010 -0400
@@ -130,17 +130,39 @@ exports.openLine = function(env, args, r
newline(model, view);
};
exports.tab = function(env, args, request) {
var view = env.get('view');
var tabstop = settings.get('tabstop');
var selection = view.getSelectedRange();
var count = tabstop - selection.start.column % tabstop;
+ var str = "";
+ var text = view.getSelectedCharacters();
+ var lines = text.split("\n");
+ var current = selection.start.row + 1;
- var str = "";
for (var i = 0; i < count; i++) {
str += " ";
}
+
+ view.replaceCharacters(selection,str + view.getSelectedCharacters());
- view.insertText(str);
+ if(lines.length > 1){
+ count = 8;
+ for (var i = 1; i < lines.length;i++){
+
+ selection = {
+ start: { row: current, column: 0},
+ end: { row: current++, column:lines[i].length}
+ }
+ view.replaceCharacters(selection," " + lines[i]);
+ }
+ }
+
+ selection = {
+ start: selection.start,
+ end: {row: selection.end.row, column:selection.end.column + count}
+ }
+
+ view.moveCursorTo(selection.end);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment