Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sublime Text: How to set up begining of line/end of line shortcuts to match the shell?

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?

like image 268
U007D Avatar asked Nov 06 '14 09:11

U007D


Video Answer


2 Answers

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.

like image 124
U007D Avatar answered Oct 17 '22 12:10

U007D


For me(on MBP):

cmd and left worked as Home

cmd and Right worked as End

Without changing any configuration in Preferences.

like image 2
0_o Avatar answered Oct 17 '22 11:10

0_o