Sublime Forum

Shortcuts to jump to sentence/paragraph start/end

#1

Hello, is it technically possible in ST to move the cursor to the beginning and end of the sentence, and paragraph?

I’ve made a little demo of desired funcitonality for sentences. Hope it explains the idea:

seq1

And here’s a demo for moving across paragraphs. By paragraph I mean, literally, a paragraph, not a visually seen line:

seq2

* * *

Something in the way has been discussed in the old threads below:

What is the shortcut key to jump to the end of line?!

0 Likes

#2

Your demo looks more like jump to next/previous sentence/paragraph, rather than jump to sentenese/paragraph start/end.


Jump to paragraph start/end can be done with builtin commands.

// to paragraph begin
{
    "keys": ["???"],
    "command": "chain",
    "args": {
        "commands": [
            ["expand_selection_to_paragraph", {"markup_aware": true}],
            ["move", {"by": "characters", "forward": false}],
        ],
    },
},
// to paragraph end
{
    "keys": ["???"],
    "command": "chain",
    "args": {
        "commands": [
            ["expand_selection_to_paragraph", {"markup_aware": true}],
            ["move", {"by": "characters", "forward": true}],
        ],
    },
},

To write a custom plugin, “sentence” sounds much more complicated since a dot doesn’t neccessarily mean the end of a sentence.

0 Likes

#3

@jfcherng I’ve included the lines below in the keymap settings, but they apparently do nothing. I tried reopening ST too.

// to paragraph begin
{
    "keys": ["alt+right"],
    "command": "chain",
    "args": {
        "commands": [
            ["expand_selection_to_paragraph", {"markup_aware": true}],
            ["move", {"by": "characters", "forward": false}],
        ],
    },
},

Also, it’s unclear how with only one hotkey I could move forward and backward.

And on the second thought, yes, all I need is just jumping between beginnings of paragraphs and sentences. Jumping between their ends isn’t necessary.

0 Likes

#4

Not sure why it’s not working for you but I do test them and they worked. The only issue is that it can’t jump back to the “begin” of the paragraph after jump to the “end” of the paragraph.

I don’t think ST reads your mind, so just use two different keybindings.

0 Likes

#5

I doubt this can be done without custom plugins. But maybe someone has created a plugin for this.

Didn’t try

0 Likes

#6

Thanks! But this one is for ST2 and it’s not among Package Control options.

I’ve added both parts (jump to start and end) to the keymap: jump to end works, jump to start doesn’t, as you mentioned.

0 Likes

#7

It looks like this author has partially solved the problem of moving sentence by sentence. See the section about pattern_navigate function: https://benfrain.com/the-surprising-extensibility-of-sublime-text/

I’ve tested the plugin in ST4 and it works. However it isn’t possible to select text sentence by sentence. Is there an easy way to do so?

0 Likes