Sublime Forum

Selecting Lines

#1

Hello all, I’m new to Sublime Text and have a question regarding selection behavior. I just installed the OpenURL plugin, as my previous editor was EditPad Pro and I grew attached to the clickable URLs (which btw would be an amazing feature to port over to Sublime if someone would like to take up that task, I was pretty shocked it’s not a default feature already). My problem is this; the plugin features the option to open file paths, however when you select a path via the line # it includes the line break at the end of the selection. This breaks the Explorer functionality of the plugin and instead forces a browser search to pop up. I’d like to avoid having to manually select the entire path by mouse dragging every time, so my question is this…
Is there a way to change the default behavior of ST to not include the line break when selecting a line via the line #? I’m hoping this might be the easier route by simply changing a setting rather than having to depend on the plugin developer or waiting until I’ve learned enough Python to edit the plugin myself.

Any help would be appreciated, thanks for your time.

0 Likes

#2

Expand Selection to Line then Shift + Left to exclude line break

0 Likes

#3

Thanks for the reply, but that’s not quite what I was looking for. I’m looking for a way to change the behavior without having to use a subsequent hotkey functionality. I don’t want the line break selected at all. Using your expand then shift+left hotkey method does work for making use of the Explorer functionality, but I’m trying to cut down on keystrokes. Is there a way to make your method into a macro so I could do it all in one action rather than multiple?

0 Likes

#4

Here is the macro you may want:


	{
		"args":
		{
			"to": "line"
		},
		"command": "expand_selection"
	},
	{
		"args": null,
		"command": "split_selection_into_lines"
	},
	{
		"args": null,
		"command": "copy"
	}
]

I usually save my macros in X:\Users\{user name}\AppData\Roaming\Sublime Text 2\Packages\User\macros directory, and you can assign a keyboard shortcut to it, like this:
{ “keys”: “ctrl+alt+c”], “command”: “run_macro_file”, “args”: {“file”: “Packages/User/macros/copy_line_wo_cr.sublime-macro”}}

0 Likes

#5

That worked perfectly thanks! Now I just need to figure out what hotkey to use lol. Thinking maybe I can combine this macro with the plugin function to make the necessary changes for it to work all in one go. I’ll post again if/when I figure something out. Thanks for your help.

0 Likes