Sublime Text has a somewhat hidden feature to automatically reindent the current line. It would be wasteful to bind this to a keybinding, I prefer it to be automatic.
print("Executing a function")
def someFunction():
return 5
Moving the print line one line down with ctrl+shift+down will result in
def someFunction():
print("Executing a function")
return 5
Instead of
def someFunction():
print("Executing a function")
return 5
I hacked this together, if someone could make a plugin for this, I would be very grateful :)
First, drop this file into your Sublime's Packages/User folder.
Name it run_multiple_commands.py
.
Now open your user keybindings, and insert this snippet:
{
"keys": ["ctrl+shift+up"],
"command": "run_multiple",
"args": {
"commands": [
{"command": "swap_line_up", "context": "window"},
{"command": "reindent", "context": "window"}
]
}
}, {
"keys": ["ctrl+shift+down"],
"command": "run_multiple",
"args": {
"commands": [
{"command": "swap_line_down", "context": "window"},
{"command": "reindent", "context": "window"}
]
}
}
How does it work? The linked script, run_multiple_commands.py let's you run multiple commands (duh) on keybindings, by simply appending the reindent command to the swap_line_up and swap_line_down commands, you get automatic reindentation! :D