Sublime Forum

Reindent after swap_line_up and swap_line_down

#1

I’ve been wanting this feature for awhile, and actually think it should be standard. For those of you wanting your selection to reindent itself when moving it up and down through your code, just add this line to the end of SwapLineUpCommand#run and SwapLineDownCommand#run in Packages/Default/swap_line.py:

self.view.run_command("reindent")

Pretty simple. Now when swapping lines around you get this:

if (true) { } return true;
swap “return true;” line up

if (true) { return true; <-- note the indentation }
instead of the default behavior:

if (true) { } return true;
swap “return true;” line up

if (true) { return true; <-- note the indentation }

0 Likes

#2

Modifying Default packages is never a good idea, you will loose your modification at each ST2 update.
You had better to create macros and override the standard keybindings with a call to your sublime-macro:

{ "args": null, "command": "swap_line_up" }, { "args": { "single_line": true }, "command": "reindent" } ]

0 Likes