2

In Sublime Text, what's the best way to jump between / over paragraphs?

For example, if my cursor is on the empty line after bar's end statement, how do I jump to the empty line between foo and bar?

def foo
  ...
end

def bar
 ...
end

^

And how do I do this while also selecting bar, as if I held down shift while moving the caret up line-by-line with the arrow keys?

1 Answer 1

3

This question was answered here in the Sublime Text forum, with contributions from jps, tobia, adzenith, and others.

The best way to achieve this is adding the following keybindings to your .sublime-keymap file, which can be opened via Preferences -> Key Bindings in the top menu. You don't need to install any Packages.

 {
    "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": ["alt+shift+up"],
    "command": "move",
    "args": {
      "by": "stops",
      "empty_line": true,
      "forward": false,
      "extend": true
    }
  },

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

On Linux, the select_lines command to create multiple carets is already bound to "alt+shift+up/down" by default, so you need to remap it if you want to avoid losing that shortcut. I recommend "alt+control+up/down" which is unused by default.

  {
    "keys": ["alt+control+up"],
    "command": "select_lines",
    "args": { "forward": false }
  },

  {
    "keys": ["alt+control+down"],
    "command": "select_lines",
    "args": { "forward": true }
  }

The situation might be different on Windows and OSX. If you have info on that, please leave a comment and I'll update the answer!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .