Sublime Text 3 comes with formatting code (reindent)

When I usually use sublime, it's annoying to see when the code is messy, and I don't bother to install any plug-ins. Later, I found that sublime actually has its own code formatting function, and most people don't find it.

The function name is reindent. If the SublimeText Chinese package is used, its name is "indent again"

path: Edit - Line - Reindent (the Chinese path is: edit - line - indent again)

There are articles on the Internet that this function does not The formatting function needs to be selected after the code is selected. The default is to format the code in the entire file; after personal testing, this is not the case. Which line the cursor stops on, after using this function, it only performs indentation to the right A simple function of , independent of the current code structure, it only performs indentation. And only when all the codes are selected and the function is executed, the code will be formatted

. Reindent function By default, sublime does not assign shortcut keys. You can perform the following operations to set shortcut keys

. 1. Open the interface for setting shortcut keys (divided into left and right parts Area, the left side is the editor default, usually in order to ensure that the normal function is not affected, the default settings on the left are not modified, but the User area on the right is modified):

Preferences → Key Bindings – User

2. Add code in it, and the shortcut key combination can be used as needed Settings:

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

 

In actual use, the effect of code formatting is not perfect. For example, when formatting an XML file, some empty tag segments will not occupy a single line, but will be crowded on the same line, affecting reading.

A more perfect solution is to install related formatting plugins in Package Control

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325443590&siteId=291194637