51

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.

sashoalm
  • 75,001
  • 122
  • 434
  • 781
Thanx
  • 7,403
  • 5
  • 21
  • 12

8 Answers8

58

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

Smashery
  • 57,848
  • 30
  • 97
  • 128
  • 2
    hmm.. I'm working on a Norwegian keyboard and to make the '[' I have to hold down Alt Gr, but still its still want do the trick. – Thanx Apr 26 '09 at 12:28
52

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.

Craig McQueen
  • 41,871
  • 30
  • 130
  • 181
35

Depends on your editor.

Have you tried Shift+Tab?

Loïc Wolff
  • 3,205
  • 25
  • 26
9

in pythonwin,

SHIFT + TAB works

JMVDA
  • 191
  • 2
  • 6
7

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+["

Alfred
  • 71
  • 1
  • 2
5
Shift-Tab
Ctrl-Tab
< key

depends on your editor.

Rook
  • 60,248
  • 49
  • 165
  • 242
2

In Jupyter Notebook,

 SHIFT+ TAB(to move left) and TAB(to move right) movement is perfectly working.
Saurav
  • 163
  • 2
  • 4
  • 1
    He is asking the question about python idle not about Jupyter notebook? – Gayal Kuruppu May 17 '20 at 08:09
  • But often, Even if someone is looking for Jupyter notebook solution for the same, this link comes up. That is what exactly happened to me. So I thought of posting the answer to the notebook here. I hope it makes sense to you @GayalKuruppu !! – Saurav May 18 '20 at 09:33
  • no @Saurav SHIFT and SHIFT+TAB is used universally in most of the languages. it is not only for jupyter notebook. Every other editor uses that. IDLE is an exception here. Thats why the answer should be specific for that. Besides, your answer is given already as "Try shift + tab if you uses some other editors". Try to add something valuable to the question. – Gayal Kuruppu May 18 '20 at 09:42
1

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.)

K. R.
  • 11
  • 5