Indenting code in Sublime text 2?

后端 未结 20 2258
没有蜡笔的小新
没有蜡笔的小新 2020-11-28 17:19

In Visual Studio I can press Ctrl+K+D to indent everything so the code is structured nicely and readable. Is there a shortcut in Sublime 2 t

相关标签:
20条回答
  • 2020-11-28 17:45
    { "keys": ["f12"], "command": "reindent", "args": {"single_line": false} } 
    

    You can get the reindent option by using the above code

    0 讨论(0)
  • 2020-11-28 17:47

    For those interested it is easy to change but for a lover of Netbeans and the auto-format you can change the key binding from F12 to ctrl+shift+F to use your beloved key binding. Sad part is that you have to select all to format the entire file. Netbeans still has the upper hand on that. If anyone knows how to overcome that limitation I'm all ears. Otherwise happy reindenting (auto-formating).

    0 讨论(0)
  • 2020-11-28 17:48

    First open the sublime text.
    than open preferences.
    than open Key Bindings -User.
    than put the below code

    [{"keys": ["ctrl+shift+c"], "command": "reindent"},]

    I use CtrlShiftC and you also use other short cut key.

    0 讨论(0)
  • 2020-11-28 17:49

    You can find it in EditLineReindent, but it does not have a shortcut by default. You can add a shortcut by going to the menu PreferencesKeybindingsUser, then add there:

    { "keys": ["f12"], "command": "reindent", "args": {"single_line": false} }  
    

    (example of using the F12 key for that functionality)

    The config files use JSON-syntax, so these curly braces have to be placed comma-separated in the square-brackets that are there by default. If you don't have any other key-bindings already, then your whole KeybindingsUser file would look like this, of course:

    [
        { "keys": ["f12"], "command": "reindent", "args": {"single_line": false}}
    ]
    
    0 讨论(0)
  • 2020-11-28 17:49

    The reindent command only works on the currently selected lines unless the "single_line" argument is set to false.

    { "keys": ["f12"], "command": "reindent", "args": {"single_line": false} }
    

    Now, pressing f12 will reindent the entire document.

    0 讨论(0)
  • 2020-11-28 17:50

    You can add a shortcut by going to the menu PreferencesKeybindingsUser, then add there:

    { "keys": ["f12"], "command": "reindent", "args": {"single_line": false} }  
    
    0 讨论(0)
提交回复
热议问题