Sublime-text Custom Shortcut key method

Source: Internet
Author: User
Tags sublime text

has recently been using sublime for project development. Often forget some of the most frequently used shortcuts. A special headache.

Sometimes it feels like some shortcuts are not very easy to use. So you're doing the right thing to define your own shortcut keys.

In fact, everyone's habits are different, so I do not like to see the network of those so-called shortcut key encyclopedia or something. How much can you remember, you see?

The first thing to say is where to define our shortcut keys.

Open Sublime Text--> preferences

We can see two options.

Key Bindings-default//This represents the system default shortcut key.

Key Bindings-user//This represents the user-defined shortcut key. The default is empty.

All we have to do is modify the Key bindings-user this file ...

Be careful not to make any changes to our default file, once you have changed the wrong one. You're a tragedy, you don't know what's wrong. You can only download the installation again or delete all the shortcuts. This is not what we want to see.

We click this Key bindings-user this option and a file default (Windows) will pop up. Sublime-keymap This JSON-formatted file.

Yes, our shortcut key definition uses the JSON format.

This is used in the form of an array object.

[{Object},{Object}] This format ...

Here, of course, we need to pay attention to some considerations in writing JSON format files.

1. Each property of the object is surrounded by "double quote".

2. The end of the last object cannot be ended with a comma (,)

3 Use commas (,) as delimiters between each object.

4. Objects can be nested inside the object.


Mmm ..... I want to remember so much should be enough ...

OK, so let's start from Stratch to create our shortcut key.

First of all


[

Here we can write our comments ...

{"Keys": ["Ctrl+k"], "command": "Toggle_side_bar"}

Do not miss the following things oh ....

Also, I do not allow the above comma Oh, otherwise I will pop up the annoying window,haha!

]

Well, for the first time, we'll copy one of the options in that default.

Note that the following can not be a comma (,) or an error ...

What do you mean by that?

1.keys indicates which shortcut key combination to use

2.command represents what command will be executed.

We can only use the reference in default to know what the orders are.

Here Toggle_side_bar represents the left menu bar display and hidden toggle is not the meaning of the switch ...


Okay, let's go ahead and create ...

[

{"Keys": ["Ctrl+k"], "command": "Toggle_side_bar"},

{' Keys ': [' alt+l '], ' command ': ' Move ', ' args ': {' by ': ' characters ', ' Forward ': true}}

]


Well, here, compare it to the above, where the comma needs to be noticed.

In one even though we use this one more

3.args this represents the parameters required by the command.

Our order is move (moving) right, so how do we move? This is a problem.

Well, the argument gives us a hint "by": "Characters" means moving by character, "forward": true means moving forward (left).

To unite is to move the cursor one character to the left by one character ...

Wow,so Cool, right?

MM-Hmm.

Now, of course, are you going to associate yourself with that? What if I want to move according to the word? That's not using

"By": "Words"? I can only say maybe, this need you to grope, I tell you you can never remember, can only try to be able to remember deeply. Have a deep memory ...

Will you do it yourself now?

Create your own custom shortcut keys. For example, you are particularly accustomed to using our VIM editor, hoping to find the kind of feeling that use vim here,

I personally recommend using ALT + * Those series of key combinations to simulate our vim editor ...

Best Wishes.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.