Home > Web Front-end > JS Tutorial > body text

SublimeText comes with the reindent_javascript technique for formatting code

WBOY
Release: 2016-05-16 15:23:06
Original
2971 people have browsed it

This is a method that Xiaojue has just found to format code in SublimeText. In fact, the function of formatting code is a function of SublimeText itself, but it has not been discovered by Xiaojue.

In the past, Xiaojue copied the code for formatting code and then pasted it into the online webmaster tool to format the code. However, after Xiaojue tested the following formatting code function that comes with SublimeText, Xiaojue thought that this This is already a redundant step.

So, having said that, how should we use SublimeText’s built-in formatting code function?

This function is named reindent by SublimeText. If you use the SublimeText Chinese package, it is called "reindent", but this name does not make sense.

The path of this option: Edit - Line - Reindent (the Chinese path is: Edit - Line - Reindent)

At the same time, please note that this function does not require selecting the code to perform the formatting function. The default is to format the code in the entire file.

Let’s talk about the theme next. How to set the shortcut key combination for the formatting code function?

1. First open the user key binding file through the following path:

Preferences → Key Bindings – User

2. Then add the following code (if you need, you can define the shortcut key combination yourself):

{"keys": ["ctrl+shift+r"], "command": "reindent" , "args": {"single_line": false}}

Please note here that each group of shortcut key combinations contains a square bracket. A group of shortcut keys is defined through curly brackets, and then separated by English commas. For details, please refer to the figure below:

Is this the end of this article? No, if the formatting code that comes with SublimeText is not suitable for the language you are using (such as SQL, Ruby, etc.), you can configure it through a plug-in. Please see the following for details:

1. The following content is based on the fact that you have installed package control in your SublimeText (tutorials are available on this site);

2. Use the shortcut key combination ctrl+shift+P to call up the command panel

3. Enter “install package” in the panel and press Enter

4. Then enter "format" (which means formatting) and find the language corresponding to the formatting operation you want to perform in the pop-up list. See the picture for details:

The above content is the entire description of reindent, the formatting code function of SublimeText, introduced by the editor to you. I hope you like it.

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template