Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove tab indent from several lines in IDLE?

If you want to indent several lines in Python IDLE you just mark the lines and hit Tab. But what if you want to remove the indent from several lines? Shift+Tab does not work for that in IDLE.

like image 921
Thanx Avatar asked Apr 26 '09 11:04

Thanx


People also ask

How do you remove indents from multiple lines?

If you're using IDLE, you can use Ctrl+] to indent and Ctrl+[ to unindent.

How do you change the indent of multiple lines in Python?

Every code editor worth its salt has a one-key way to indent and dedent blocks. In IDLE (the IDE included with Python), CTRL + [ dedents and CTRL + ] indents. Selecting text then using the shift+tab shortcut also works if you're using the Python editor built into Canopy on Windows.

How do you Unindent multiple lines of code in Python?

Thanks for your help, it is Ctrl + [.


8 Answers

If you're using IDLE, you can use Ctrl+] to indent and Ctrl+[ to unindent.

like image 190
Smashery Avatar answered Oct 03 '22 18:10

Smashery


If you're using IDLE, and the Norwegian keyboard makes Ctrl-[ a problem, you can change the key.

  1. Go Options->Configure IDLE.
  2. Click the Keys tab.
  3. If necessary, click Save as New Custom Key Set.
  4. With your custom key set, find "dedent-region" in the list.
  5. Click Get New Keys for Selection.
  6. etc

I tried putting in shift-Tab and that worked nicely.

like image 25
Craig McQueen Avatar answered Oct 03 '22 17:10

Craig McQueen


Depends on your editor.

Have you tried Shift+Tab?

like image 38
Loïc Wolff Avatar answered Oct 03 '22 19:10

Loïc Wolff


in pythonwin,

SHIFT + TAB works

like image 25
JMVDA Avatar answered Oct 03 '22 17:10

JMVDA


For IDLE, select the lines, then open the "Format" menu. (Between "Edit" and "Run" if you're having trouble finding it.) This will also give you the keyboard shortcut, for me it turned out that dedent shortcut was "Ctrl+["

like image 38
Alfred Avatar answered Oct 03 '22 19:10

Alfred


Shift-Tab
Ctrl-Tab
< key

depends on your editor.

like image 30
Rook Avatar answered Oct 03 '22 18:10

Rook


In Jupyter Notebook,

 SHIFT+ TAB(to move left) and TAB(to move right) movement is perfectly working.
like image 20
Saurav Avatar answered Oct 03 '22 19:10

Saurav


By default, IDLE has it on Shift-Left Bracket. However, if you want, you can customise it to be Shift-Tab by clicking Options --> Configure IDLE --> Keys --> Use a Custom Key Set --> dedent-region --> Get New Keys for Selection

Then you can choose whatever combination you want. (Don't forget to click apply otherwise all the settings would not get affected.)

like image 45
K. R. Avatar answered Oct 03 '22 19:10

K. R.