Sublime Text 2 Code Formatting

后端 未结 4 557
醉梦人生
醉梦人生 2021-01-30 00:55

First let me say I come from a Microsoft background and Visual Studio is my bread and butter. It has a command (keybind is arbitrary) that auto-formats any code syntax

4条回答
  •  我在风中等你
    2021-01-30 01:17

    A similar option in Sublime Text is the built in Edit->Line->Reindent. You can put this code in Preferences -> Key Bindings User:

    { "keys": ["alt+shift+f"], "command": "reindent"} 
    

    I use alt+shift+f because I'm a Netbeans user.

    To format your code, select all by pressing ctrl+a and "your key combination". Excuse me for my bad english.


    Or if you don't want to select all before formatting, add an argument to the command instead:

    { "keys": ["alt+shift+f"], "command": "reindent", "args": {"single_line": false} }
    

    (as per comment by @Supr below)

提交回复
热议问题