Indenting code in Sublime text 2?
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 to do the same?
You can find it in Edit
→ Line
→ Reindent
, but it does not have a shortcut by default. You can add a shortcut by going to the menu Preferences
→ Keybindings
→ User
, 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 Keybindings
→ User
file would look like this, of course:
[
{ "keys": ["f12"], "command": "reindent", "args": {"single_line": false}}
]
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.
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
链接地址: http://www.djcxy.com/p/62366.html上一篇: 查看空白字符