Python Forum

Full Version: cheating with indented code
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
i had a block of code in a loop. i needed to copy it to a place before the loop to initialize some things. it was already indented one level too much. but rather than edit all those lines to unindent them (and because i might need to copy them back with changes) i cheated. i created a FAKE block that began with "if 1:". now i can just leave them indented.
well, every decent IDE has a key combinations to indent and de-dent block of code.
e.g. in VS Code, select a block of code and Tab will indent one level Shift+Tab will de-dent one level. Same in Notepad++. No need of this weird stuff with fake if block.
In Kate or Kdevelop it is Ctrl-I and Ctrl-Shift-I.
how about emacs (version 25.2)?
I don't use emacs, but quick lool in the docs show there are 2 commands to indent and dedent regions of lines:
https://www.gnu.org/software/emacs/manua...n-Commands

Look at the last 2 in the above link.