Sublime Forum

How to create hotkey for Expand Selection to Paragraph?

#1

Hi there,
I’ve been trying to create a hotkey for expand selection to paragraph with no luck, the following line is what I put into my user keymap file, I need help to figure out which arg stands for ‘paragraph’, Thank you!!

{“keys”: “ctrl+shift+,”], “command”: “expand_selection”, “args”: {“to”: “paragraph”} }

0 Likes

#2

There’s no such option as far as I’m aware of.

But if you don’t use hard-wrap then a paragraph is identical to a line. So you can select it by the same keybinding you use to expand the selection to a line (Ctrl+L on Win/Lin; not sure on OSX).

Now, expand selection to sentence… that’s what I’d like to see :smile: It’s probably doable via a plugin, if you’re not very picky.

Alex

0 Likes

#3
{"keys": "ctrl+shift+,"], "command": "expand_selection_to_paragraph" }
0 Likes

#4

Huh. Learn something new every day :smile:

I don’t get it, though. How is this different than the expand selection to line?

0 Likes

#5

To bizoo:
Thank you ! That works, but how do you get that command?

[quote=“bizoo”] {"keys": "ctrl+shift+,"], "command": "expand_selection_to_paragraph" } [/quote]

To quodlibet:
“expand_selection_to_paragraph” to “expand_selection_to_line” is sort of like “expand_selection_to_line” to “expand_selection_to_word”

0 Likes

#6

[quote=“kurtwong”]To bizoo:
Thank you ! That works, but how do you get that command?
[/quote]

  • Go to your ST3 installation folder (“C:\Program Files\Sublime Text 3\Packages” in Windows 64b).

  • Open the file Default.sublime-package with the archiver of your choice (it’s a zip file).

  • Open the Main.sublime-menu file inside the archive which contains the ST menus definitions.

  • Search for “Expand Selection to Paragraph” to find the command linked to this menu item.

0 Likes

#7

[quote=“quodlibet”]Huh. Learn something new every day :smile:

I don’t get it, though. How is this different than the expand selection to line?[/quote]

expand_selection_to_paragraph come from a Python script paragraph.py:

class ExpandSelectionToParagraphCommand(sublime_plugin.TextCommand):

Others are built-ins commands.

0 Likes

#8

I see. That’s great! I never use the menus. It’s annoying that the built-in commands are not all in the command palette.

Oh, wait:
github.com/fjl/Sublime-Missing- … -Commands/

I love this community :smile:

0 Likes

#9

Sadly,

{"keys": ["ctrl+shift+,"], "command": "expand_selection_to_paragraph" },

stopped working on Sublime Text 4. It ignores lines that start with - now

For example the following SQL query is not longer selected,

SELECT *
-- This is a comment, this line is not selected for the paragraph.
FROM my_table;
0 Likes