Indenting code in Sublime text 2?

后端 未结 20 2257
没有蜡笔的小新
没有蜡笔的小新 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:30

    Just in case this stop working for anyone like me, in OS X, the command key is identified as superso it should be able to do something like this:

    [
        {
        "keys": ["super+i"], 
        "command": "reindent", 
        "args": {
            "single_line": 
            false}
        } 
    ]
    

    in this case using command+i is going to indent your whole code (eclipse like :) )

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

    For those who like the default key binding for IntelJ IDEA, select Preferences > Settings - User:

    And paste in the following to have the command + shift + l shortcut for auto indent:

    [
       { "keys": ["command+shift+l"], "command": "reindent"}
    ]
    
    0 讨论(0)
  • 2020-11-28 17:32

    No one seems to love mac re-indentation, So here How I do it:

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

    In Preferences > Key Binding - User

    One more extra tip: add

    { "keys": ["command+0"], "command": "focus_side_bar" }
    

    to have sidebar file tree view navigation using keyboard.

    Note: Add , at the end of each {}, if you have more than one {} set of objects

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

    For Auto-Formatting in Sublime Text 2: Install Package: Tag from Command Palette, then go to Edit -> Tag -> Auto-Format Tags on Document

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

    To indent with the same keys like Visual Studio Ctrl+K+D (I am a Visual Studio user so I am used to this combination) I suggest:

    [
    { "keys": ["ctrl+k", "ctrl+d"], "command": "reindent", "args": {"single_line": false} }
    ]
    

    Write this on Preferences>Key Bindings - User

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

    Beside of the inbuilt 'reindent' function, you can also install other plugins, such as SublimeAStyleFormatter and CodeFormatter. These plugins are better for their specify language.

    0 讨论(0)
提交回复
热议问题