Home Download Buy Blog Forum Support

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

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

Postby Ysgard on Sat Mar 16, 2013 6:34 am

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?
Last edited by Ysgard on Mon Mar 18, 2013 3:09 am, edited 1 time in total.
Ysgard
 
Posts: 4
Joined: Sat Mar 16, 2013 6:24 am

Re: ST3 Keybind doesn't work - bug or bad config?

Postby skuroda on Sat Mar 16, 2013 6:40 am

The command is "move_to" not "moveto". Note the underscore.
skuroda
 
Posts: 676
Joined: Fri Oct 05, 2012 8:11 am

Re: ST3 Keybind doesn't work - bug or bad config?

Postby Ysgard on Sat Mar 16, 2013 6:46 am

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?
Ysgard
 
Posts: 4
Joined: Sat Mar 16, 2013 6:24 am

Re: ST3 Keybind doesn't work - bug or bad config?

Postby Ysgard on Sat Mar 16, 2013 6:48 am

...ah crap, I missed the underscore. Thank you. :oops:

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?
Ysgard
 
Posts: 4
Joined: Sat Mar 16, 2013 6:24 am

Re: ST3 Keybind doesn't work - bug or bad config?

Postby skuroda on Sat Mar 16, 2013 9:43 am

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: Select all
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


Then in your key map you will have

Code: Select all
[
    { "keys": ["shift+space"], "command": "my_move_to"}
]
skuroda
 
Posts: 676
Joined: Fri Oct 05, 2012 8:11 am

Re: ST3 Keybind doesn't work - bug or bad config?

Postby Ysgard on Mon Mar 18, 2013 3:09 am

Ha! That's perfect, thank you! :D
Ysgard
 
Posts: 4
Joined: Sat Mar 16, 2013 6:24 am


Return to Technical Support

Who is online

Users browsing this forum: Exabot [Bot], Yahoo [Bot] and 20 guests