Hi:
As Python does not have braces, it is hard for SE to know the desired level of indenting when copy/pasting code. However as the programmer, I know the desired level of indenting. I'd like to have a macro (or macro(s)) in SE so that I can tell SE which level of indenting to use.
For example, lets say I have this code:
while (argv_idx < argvLen):
if sys.argv[argv_idx] == "-d":
argv_idx = argv_idx + 1
description = sys.argv[argv_idx]
description = description.replace(" ","-")
if sys.argv[argv_idx] == "-u":
compressed = False
and then I want to paste the following at the end:
if sys.argv[argv_idx] == "-r":
compressed = False
argv_idx = argv_idx + 1
reviewnum = sys.argv[argv_idx]
When I do this, I get it with undesired indenting, because SE thinks it should continue with current indenting:
while (argv_idx < argvLen):
if sys.argv[argv_idx] == "-d":
argv_idx = argv_idx + 1
description = sys.argv[argv_idx]
description = description.replace(" ","-")
if sys.argv[argv_idx] == "-u":
compressed = False
if sys.argv[argv_idx] == "-r": # I really wanted this 4 spaces over to the left, not where it was pasted.
compressed = False
argv_idx = argv_idx + 1
reviewnum = sys.argv[argv_idx]
But what I really desire is this:
while (argv_idx < argvLen):
if sys.argv[argv_idx] == "-d":
argv_idx = argv_idx + 1
description = sys.argv[argv_idx]
description = description.replace(" ","-")
if sys.argv[argv_idx] == "-u":
compressed = False
if sys.argv[argv_idx] == "-r": # Now this line has the desired indent
compressed = False
argv_idx = argv_idx + 1
reviewnum = sys.argv[argv_idx]
To fix it, I need to do column select and then "Shift-Tab" to move it to the correct indenting. It is doable, but tedious.
Since I as the programmer know the desired level of indenting, if SE could provide me with a macro (that I can bind to a key) to tell SE to paste this code with the previous level of indenting, it would make me more productive.
So if 2 macros are provided - paste_python_with_current_indent and paste_python_with_previous_indent, then I could bind both to a key and know exactly which level of indent I am pasting to.