user17038038
user17038038

Reputation: 136

How to select a line without selecting the line break at the end of it in Sublime Text?

When I click on the line number at the left or if I triple click the text in the line, I don't want the following new line/line break to be selected. Is there any simple way to change the settings for this? It would save a lot of time when copying/pasting.

Upvotes: 2

Views: 648

Answers (1)

Craig Jones
Craig Jones

Reputation: 2627

This won't help with clicking on the line number, but here's how you can change the triple-click. In Default (Windows).sublime-mousemap, the triple-click is defined like this:

    // Drag select by lines
    {
        "button": "button1", "count": 3,
        "press_command": "drag_select",
        "press_args": {"by": "lines"},
    },

You can override that definition by creating a corresponding Default (Windows).sublime-mousemap file in your User package, and then redefine it like this:

[
    // Drag select by lines
    {
        "button": "button1", "count": 3,
        "press_command": "drag_select",
        "press_args": {"by": "lines"},
        "command": "move",
        "args": {"by": "characters", "extend": true, "forward": false}
    },
]

Note: The press_command/press_args lines are what happens on the button's way down (the third time in this case). Adding the command/args lines tells it what to do when the button comes back up.

Likewise, you can define an alternative to the Expand Selection to Line command keybinding (ctrl+L) in your User\Default (Windows).sublime-keymap:

    { "keys": ["alt+l"], "command": "chain", "args": {
     "commands": [
        ["expand_selection", {"to": "line"}],
        ["move", {"by": "characters", "extend": true, "forward": false}],
        ]
        }
    }

In this case, you can't have two command/arg lines directly in the same binding, so we go through the "chain" command.

Upvotes: 1

Related Questions