Sublime Forum

How to remove from multiple text selection

#1

with multiple text selection how can I exclude a particular selection afterwards?

I found from the ST2 documentation the following hint:

work with multiple selections:

Ctrl to add to the selection
Alt to remove from the selection

I wasn’t able to make this work, nor did I find a "alt" key binding. Any help?

I am using ST 3.2.1 B3207 on Linux Ubuntu.

Thank you

0 Likes

#2

Those seem like the correct keys for Linux; it sounds like you may be running into issues with the window manager eating keys on you.

I don’t use it personally, but if I recall correctly Ubuntu uses the Alt key in combination with a mouse drag to move a window as if you grabbed the title bar. Other distributions/window managers often do something similar. Way back in the mists of time I recall having to configure XFCE not to do that so that I could work in Blender, for example.

Depending on your Ubuntu version this may or may not be the issue, or the window manager you use might be using that key sequence for something else entirely as well.

To check, open the Sublime console with Ctrl+` or View > Show Console and enter sublime.log_commands(True), followed by holding Alt while dragging the mouse in an open file.

If Sublime is seeing things properly, you should see the console reporting the drag_select command being called with an argument of "subtractive": true; for example:

command: drag_select {"event": {"button": 1, "x": 321.469390869, "y": 344.05065918}, "subtractive": true}

If you don’t see anything, then most likely the window manager is using that sequence, which stops Sublime from being able to see it happening. If you see a response but it’s some other command, then a package that you’ve installed is interfering with the normal mouse bindings.

In the first case, there may be settings somewhere in the window manager/desktop environment you use to change that global shortcut to something else so that it doesn’t collide. For the second case, that’s an issue to take up with the author of the package in question.

The bindings for this functionality aren’t in standard sublime-keymap files because they involve the mouse; mouse actions are controlled by sublime-mousemap files instead. You can use View Package File to open Default/Default (Linux).sublime-mousemap to see the default bindings.

This file has the entries that are responsible for this feature; for example:

	{
		"button": "button1", "count": 1, "modifiers": ["alt"],
		"press_command": "drag_select",
		"press_args": {"subtractive": true}
	},

There are also variations on this for being subtractive while also extending the selection, removing words and lines, and so on.

Similar to key bindings you can create a similarly named file in your User package that contains your specific modifications, and your custom file will override the default for whatever items you put in it. You’d want to include in your file only the entries that you want to modify, not the whole file (just like in the key bindings files).

3 Likes