How to move X number of lines?


For example, I want to map a keyboard shortcut that moves up 10 lines at a time. How might I do that?

In vim-mode, I can achieve the same by typing 10k to move up by 10 lines. How would I map ctrl-k to do the same thing?


This would be the function you’re looking for.


@DamnedScholar Seems so! How do we obtain the instance? Or is there a command associated with it?


Putting this in your will do what you want.

atom.commands.add 'atom-text-editor', 'user:up-10-lines', ->
    return unless editor = atom.workspace.getActiveTextEditor()


And you can bind the command simply enough.

   'ctrl-k': 'user:up-10-lines'

Keep in mind that ctrl-k has a variety of bindings attached to it already, so if you press that combination by itself, you’ll have to type something else so that Atom realizes you’re not using one of the other combinations.


Thanks a ton!

I noticed that (with cmd-k on OS X)! Is there a way to disable all of those (since I’m not using them), so the delay can be gone?


You can unset bindings. I personally feel like the number of bindings attached to that key already makes it not worthwhile. Are all of your modifier keys spoken for when it comes to the direction pad? Because a modifier key and up or down would be pretty intuitive.


Coming from Vim, IJKL with H as the insert key is similarly intuitive to the direction pad, which is what I had for a good while, but I’ve recently settled with Vim’s HJKL with I as the insert key since it works everywhere with less configuration.

What are the implications of

  'cmd-k': 'unset!'

, if any?


For your purposes? None, because you’re going to have to unset each keybinding, from cmd-k cmd-0 down through cmd-k up.