Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ctrl + D select in reverse

Tags:

sublimetext2

Is there a way to do the reverse selection in Sublime Text 2?

I know that you can skip (Ctrl + K, Ctrl + D), undo (Ctrl + Y) and cherry pick (hold alt) your selection from Ctrl + D but how do I tell sublime to multi-select in reverse order?

Let's say, instead of going up to down, I want to go down to up.

like image 787
shriek Avatar asked Oct 09 '13 00:10

shriek


1 Answers

If anyone can please improve upon this plugin so that it scrolls the screen upwards as it selects, that would be greatly appreciated.


NOTE:  The OSX key binding that I chose for this example conflicts with duplicate_line, so that key binding would need to be commented out for this new key binding to work -- otherwise, select a different key binding that is not already taken.

{ "keys": ["super+shift+d"], "command": "inverse_find_under_expand" },

import sublime, sublime_plugin

class InverseFindUnderExpandCommand(sublime_plugin.TextCommand):
    "Add the previous occurrence of the word under the cursor to the selection"

    def run(self, edit):
        sel = [s for s in self.view.sel()]

        new_sel = []

        for s in sel:
            self.view.sel().clear()
            self.view.sel().add(s)

            self.view.window().run_command('find_under_prev')

            for ns in self.view.sel():
                new_sel.append(ns)

        self.view.sel().clear()

        for s in sel:
            self.view.sel().add(s)

        for s in new_sel:
            self.view.sel().add(s)
like image 199
lawlist Avatar answered Sep 30 '22 13:09

lawlist