Sublime Forum

[SOLVED] ST3 Keybind doesn't work - bug or bad config?

#1

I’m on ST3 Build 3021 on OSX 10.8.

I’m trying to set up some keybindings, so I checked out the ST3 documentation, and went to

Sublime Text -> File -> Key Bindings - User

This opened Packages/User/Default (OSX).sublime-keymap, which looks right according to the docs. In it I placed:

{ “keys”: “shift+space”], “command”: “moveto”, “args”: { “to”: “hardeol” }},
{ “keys”: “shift+space”, “shift+space”], “command”: “moveto”, “args”: { “to”: “hardbol” }}
]

Because I used these keystrokes in Vim all the time and they are ingrained in me. I saved(no errors), and closed the file. For good measure, I opened the console and put in

sublime.log_input(True)
sublime.log_commands(True)

I then typed a random line, put my cursor in the middle, and did a Shift+Space, which I expected would put the cursor at the end of the line. It didn’t, and neither did the chord work.

Checking the console, I see

key evt: shift+space

but no command follows. I know it’s overriding the default, because the default was to add a space with shift+space. It no longer adds a space, but neither does the cursor move.

Am I missing something?

0 Likes

#2

The command is “move_to” not “moveto”. Note the underscore.

0 Likes

#3

Some more info: The chord does work, it’s the first command that doesn’t - presumably the second masks the first? Either way, I do see:

command: moveto {“to”: “hardbol”}

but the command doesn’t work - the cursor stays put. If I remove the chord command, the hardeol command surfaces instead, but the cursor doesn’t move to the end of the line. Are ‘hardbol’ and ‘hardeol’ deprecated in ST3?

0 Likes

#4

…ah crap, I missed the underscore. Thank you. :blush:

I still have the problem where the latter command masks the prior one. Is there any way to get the plain shift-space to move to the end of the line, and the quick shift-space,shift-space to go to the beginning?

0 Likes

#5

Hmm, not sure why that happens. But you can use a simple plugin. I only minimally tested this though. You can adjust that “500” to something a time you feel is “fast enough”. Note that is in milliseconds.

[code]import sublime
import sublime_plugin
import time

class MyMoveToCommand(sublime_plugin.TextCommand):
last_run_time = 0
def run(self, edit):
view = self.view
run_time = int(round(time.time() * 1000))
if run_time - self.last_run_time > 500:
view.run_command(“move_to”, {“to”: “hardeol”})
else:
view.run_command(“move_to”, {“to”: “hardbol”})
self.last_run_time = run_time[/code]

Then in your key map you will have

{ "keys": "shift+space"], "command": "my_move_to"} ]

0 Likes

#6

Ha! That’s perfect, thank you! :smiley:

0 Likes