修改 Sublime 按快捷鍵 ctrl+s 自動格式化(reindent lines)的問題

Sublime 工具自帶代碼格式化的功能,但在某些場景下格式化代碼後並非咱們想要的代碼格式,且是點擊保存ctrl+s才觸發的格式代碼事件,so,爲關閉點擊ctrl+s格式代碼,咱們須要改命令 save 的默認快捷鍵源碼javascript

1.查看ctrl+s快捷鍵的command(命令)css

Preferences -> Key Bindings - Default:命令savehtml

 

2.安裝 PackageResourceViewer 插件java

Ctrl+Shift+P -> Install Package  -> PackageResourceViewer工具

安裝後可看 PackageResourceViewer README.md 說明 :spa

"reindent_on_save": ["css", "SCSS", "html", "Js"]插件

You can specify file types which you want to be reindented on save (reindented保存指定文件類型)3d

`PackageResourceViewer: Open Resource`:htm

Command to open the resource. If saved, the correct directory structure will be created in the `Packages` folder. This command will only be displayed if the `single_command` setting is true.blog

`PackageResourceViewer: Extract Package`:

Command to extract a package to the `Packages` directory. This command is only available in ST3.

#命令操做:Ctrl+Shift+P -> PackageResourceViewer: Open Resource

#點擊PackageResourceViewer: Open Resource會彈出安裝過的插件:

#選擇 Reindent on save,彈出命令 save 的源碼設置:

#打開 ReindentOnSave.py,前面有提到設置 reindent_on_save 能夠保存指定的文件類型,因此這裏把這裏改爲 False,這樣再操做 ctrl+s 時就不會自動格式代碼了

 

 

3.將 reindent 格式化命令改爲其餘快捷鍵

在 Preferences -> Key Bindings - User 下加代碼:keys 的值可改爲其餘

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

 在 Edit -> Line -> Reindent 可查看快捷鍵的設置

相關文章
相關標籤/搜索