Sublime Forum

How to select multiple columns under Windows?

#1

I have an HP Envy with a synaptic touchpad, and I cannot select columns in ST3 at all. If I use the keyboard, and press:

Ctrl + Alt + Up
Ctrl + Alt + Down

I can select ONE column. But I am unable to select or expand my selection to include multiple columns. How can I select a rectangular area using the keyboard?

-Thanks

0 Likes

#2
  1. You create multiple columns and then just use ctrl+left and ctrl+right to increase each column
  2. I made a small plugin to not only add a caret but a whole selection. Select Tools > Developer > New Plugin… and paste this:
import sublime
import sublime_plugin


def _get_point(view, point, forward):
    delta = 1 if forward else -1
    row, col = view.rowcol(point)
    new_row = row + delta
    new_point = view.text_point(new_row, col)
    # if we moved beyond the line end, move to the end of the line
    if view.rowcol(new_point)[0] != new_row:
        new_point = view.text_point(new_row + 1, 0) - 1
    return new_point


class AddSelectionCommand(sublime_plugin.TextCommand):
    def run(self, edit, forward=True, only_caret=True):
        view = self.view
        if not len(view.sel()):
            return
        sel = view.sel()[-1 if forward else 0]
        row, col = view.rowcol(sel.b)
        point_b = _get_point(view, sel.b, forward)
        if only_caret:
            point_a = point_b
        else:
            point_a = _get_point(view, sel.a, forward)
        new_sel = sublime.Region(point_a, point_b)
        view.sel().add(new_sel)

Afterwards create a keybinding:

    {
        "keys": ["ctrl+alt+down"],
        "command": "add_selection",
        "args": {
            "forward": true,
            "only_caret": false
        }
    },
    {
        "keys": ["ctrl+alt+up"],
        "command": "add_selection",
        "args": {
            "forward": false,
            "only_caret": false
        }
    },
0 Likes

#3

Thank you, I will check it out.

0 Likes

#4

Actually I find that I can use ctrl + alt + up and down, THEN use ctrl + shift and left and right.

0 Likes