Sublime Text: How to set up begining of line/end o

2019-02-14 07:42发布

问题:

I've been using Sublime Text for a little while now (on MacBook Pro), and want to make it keystroke compatible with the shell.

In the shell, to jump to the beginning/end of line I press fn+Left/fn+Right.

In Sublime Text, I understand how to set up key bindings for fn+Left/fn+Right, but I see no key name for the fn key (not the f1, f2, etc. function keys, I am referring to the key marked "fn").

How can I make this work in Sublime Text?

回答1:

I guess I was making it too hard on myself.

  1. the fn button does not have a key name in Sublime Text.
  2. fn+Left/fn+Right is read as Home/End. Simply mapping Home and End did the job.

Specifically:

Sublime Text | Preferences | Key Bindings - User
  1. Add the following between the [ ]:

    { "keys": ["home"], "command": "move_to", "args": { "to": "hardbol" } },
    { "keys": ["end"], "command": "move_to", "args": { "to": "hardeol" } }
    

I discovered this by opening up the SublimeText console:

ctrl+`
sublime.log_input(True)

Now, typing any keys reveal their Sublime Text key names. fn did not elicit a response, but fn+Left/fn+Right yielded Home/End.

sublime.log_input(False)

Hope that helps.



回答2:

For me(on MBP):

cmd and left worked as Home

cmd and Right worked as End

Without changing any configuration in Preferences.