Sublime Forum

Jump to next empty line?


is there a way to remap ctrl-up/down to jumpt to the next empty line?

i use this for navigation in emacs all the time, and just leave an empty line as punctuation in my code…



Move cursor up or down multiple lines?

you could look at using bookmarks. Ctrl+F2 to toggle a bookmark, and F2 to go to the next one.

1 Like


You could use the code below and tweek it a bit.
My previous editor was TextPad and I used move by paragraph all the time. I missed it dearly and wrote a command for it.
I have it mapped to alt+up/down and the selecting variants mapped to ctrl+shift+up/down.
Hope this helps.

…\AppData\Roaming\Sublime Text 2\Packages\User\

[code]import sublime, sublime_plugin

class MoveByParagraphCommand(sublime_plugin.TextCommand):
def run(self, edit, extend = False, forward = True):
self.view.run_command(“move_to”, {“to”: “hardbol”, “extend”: extend}) # to mimic TextPad’s behaviour
pt = self.view.sel()[0].b
if forward:
rg = self.view.find("\n\s*\n", pt)
new_pt = rg.b if rg else self.view.size()
# couldn’t find “find previous” command
rgs = self.view.find_all("\n\s]*\n")
new_pt = 0
for rg in rgs:
if rg.b < pt:
new_pt = rg.b
new_pt_visible = self.view.visible_region().contains(new_pt)
# obviously inefficient way of doing it (couldn’t find amount for move command)
# becomes slow for veeeeery long paragraphs
self.view.run_command(“move”, {“by”: “lines”, “forward”: forward, “extend”: extend})
while (self.view.sel()[0].b < new_pt) == forward and self.view.sel()[0].b != pt:
pt = self.view.sel()[0].b
self.view.run_command(“move”, {“by”: “lines”, “forward”: forward, “extend”: extend})
while self.view.sel()[0].b != new_pt:
self.view.run_command(“move”, {“by”: “characters”, “forward”: self.view.sel()[0].b < new_pt, “extend”: extend})
if not new_pt_visible:

In …\AppData\Roaming\Sublime Text 2\Packages\User\Default (Windows).sublime-keymap:

{ "keys": "ctrl+shift+up"], "command": "move_by_paragraph", "args": {"extend": true, "forward": false} }, { "keys": "ctrl+shift+down"], "command": "move_by_paragraph", "args": {"extend": true} }, { "keys": "alt+up"], "command": "move_by_paragraph", "args": {"extend": false, "forward": false} }, { "keys": "alt+down"], "command": "move_by_paragraph", "args": {"extend": false} },

1 Like


Another option is:

{ "keys": "alt+up"], "command": "move", "args": {"by": "stops", "empty_line": true, "forward": false} },
{ "keys": "alt+down"], "command": "move", "args": {"by": "stops", "empty_line": true, "forward": true} }


[quote=“jps”]Another option is:

{ "keys": "alt+up"], "command": "move", "args": {"by": "stops", "empty_line": true, "forward": false} }, { "keys": "alt+down"], "command": "move", "args": {"by": "stops", "empty_line": true, "forward": true} } [/quote]

I was looking for the same command (curly braces in Vim command mode, I always used it) and this is the correct answer, thanks.

1 Like


Didn’t know “move by stops” exists !!!

Is there a comprehensive list of command and their arguments ?
Maybe there’s a way to generate it automatically ?

1 Like


More to the point: how do we extend the above command with shift to get selection by whole paragraphs?
(shift+alt+up/down = select up to the prev/next empty line)

This would be very useful to quickly move blocks of code around.

Is there a select by stops command?

1 Like


You can add “extend”:“true” to any movement command, I think. Just create another binding with the shift key involved.

1 Like

Jump tp next nonempty line (with skipping of multiple nonempty line)

Thank you!

This is the complete set of bindings that solve my issue:

{"keys": "alt+up"], "command": "move", "args": {"by": "stops", "empty_line": true, "forward": false}},
{"keys": "alt+down"], "command": "move", "args": {"by": "stops", "empty_line": true, "forward": true}},
{"keys": "shift+alt+up"], "command": "move", "args": {"by": "stops", "empty_line": true, "forward": false, "extend": true}},
{"keys": "shift+alt+down"], "command": "move", "args": {"by": "stops", "empty_line": true, "forward": true, "extend": true}},
1 Like


Thanks lappri,

I have been missing paragraph jumping tonnes.

1 Like


[quote=“jps”]Another option is:

{ "keys": "alt+up"], "command": "move", "args": {"by": "stops", "empty_line": true, "forward": false} }, { "keys": "alt+down"], "command": "move", "args": {"by": "stops", "empty_line": true, "forward": true} } [/quote]

Most excellent.
Trying to make the transition from TextPad. Adding this makes me feel a bit more at home.

1 Like


The syntax in all posts shown so far was incorrect, "keys": "alt+up"] lacks an open bracket [.

Here’s my fixed version:

// Jumping over blocks (to next empty line)
{"keys": ["alt+up"], "command": "move", "args": {"by": "stops", "empty_line": true, "forward": false}},
{"keys": ["alt+down"], "command": "move", "args": {"by": "stops", "empty_line": true, "forward": true}},
// With selecting
{"keys": ["ctrl+shift+alt+up"], "command": "move", "args": {"by": "stops", "empty_line": true, "forward": false, "extend": true}},
{"keys": ["ctrl+shift+alt+down"], "command": "move", "args": {"by": "stops", "empty_line": true, "forward": true, "extend": true}},


This is great - but it would be nice if it was clever enough so that, if there are two empty lines below each other, it would skip to the next non-empty line. Anybody has a suggestion for this?



Yeah, I’d like to know how to skip multiple empty lines as well. There is an extension called “Block Travel Plus” for VS Code that does that… would be nice to have the same functionality on ST :smiley:



What I did was to move to neovim instead. Steep Learning curve but worth imo

1 Like