Python Forum
cheating with indented code
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
cheating with indented code
#1
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.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#2
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.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
In Kate or Kdevelop it is Ctrl-I and Ctrl-Shift-I.
Reply
#4
how about emacs (version 25.2)?
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#5
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.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#6
Look also at https://www.gnu.org/software/emacs/manua...l#C-Indent

Last 2 paragraphs
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020