From a62cb4b578cc39540a2c69edbfa2f75239034308 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20Petr=C5=BEela?= Date: Mon, 2 May 2016 12:19:45 +0200 Subject: [PATCH] add Ctrl+K Ctrl+D support to skip last selection --- keymap/sublime.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/keymap/sublime.js b/keymap/sublime.js index d9b64ba9af..48b05757ae 100644 --- a/keymap/sublime.js +++ b/keymap/sublime.js @@ -138,9 +138,23 @@ return {from: Pos(pos.line, start), to: Pos(pos.line, end), word: line.slice(start, end)}; } + var cK = ctrl + "K "; + var canSkip = false; + cmds[map[ctrl + "D"] = "selectNextOccurrence"] = function(cm) { + findNextSelection(cm); + canSkip = true; + }; + + cmds[map[cK + ctrl + "D"] = "skipOccurrence"] = function(cm) { + if(canSkip) findNextSelection(cm, true); + canSkip = false; + } + + function findNextSelection(cm, skip) { var from = cm.getCursor("from"), to = cm.getCursor("to"); var fullWord = cm.state.sublimeFindFullWord == cm.doc.sel; + if(skip) cm.undoSelection(); if (CodeMirror.cmpPos(from, to) == 0) { var word = wordAt(cm, from); if (!word.word) return; @@ -397,8 +411,6 @@ map["Alt-Q"] = "wrapLines"; - var cK = ctrl + "K "; - function modifyWordOrSelection(cm, mod) { cm.operation(function() { var ranges = cm.listSelections(), indices = [], replacements = [];