Indentation question

D

David Lees

I have a real basic how-to question. When I decide to reuse a piece of
python code at a different indentation level than the original, is there
a common trick (or set of tricks) for moving the indentation correctly
for the whole block? Probably this is editor dependent, so if some has
a FAQ or pointer to a page please feel free to post. Typical I use
PythonWin as my editor, though sometimes I use EditPadLite (an ascii
editor).

TIA

David Lees
 
C

Christos TZOTZIOY Georgiou

[David Lees asks how to indent and unindent a group of lines in his
code, referring to PythonWin and EditPadLight]
A lot of editors use the method of:

1. Select lines of text
2. Press TAB or SHIFT+TAB to change indentation out or in
respectively.
I dont know about those editors though.

This works for PythonWin, I don't know for EditPadLite. In IDLE (in
windows at least), the keypresses are ^[ and ^] for unindenting and
indenting, respectively; check the Edit menu for the actual shortcuts.
 
D

David Lees

Christos said:
[David Lees asks how to indent and unindent a group of lines in his
code, referring to PythonWin and EditPadLight]

A lot of editors use the method of:

1. Select lines of text
2. Press TAB or SHIFT+TAB to change indentation out or in
respectively.

I dont know about those editors though.


This works for PythonWin, I don't know for EditPadLite. In IDLE (in
windows at least), the keypresses are ^[ and ^] for unindenting and
indenting, respectively; check the Edit menu for the actual shortcuts.

I just tried it in EditPad and PythonWin. It works in both. Thanks
guys, this is real handy to know.

David Lees
 
A

Anand Pillai

I can suggest two editors which does the block indentation.

1. IDLE
2. GNU Emacs

In IDLE AFAIK, this option is available as "Dedent Region"
to indent the code-block lesser, and "Indent Region" to indent
it more, i.e to the right.

In GNU Emacs, you can mark the region you want to indent/dedent,
go to the Editor menu and say, "Indent Right More", "Indent Left More",
etc which respectively indents the code-block more to the right
and more to the left.

-Anand

David Lees said:
Christos said:
[David Lees asks how to indent and unindent a group of lines in his
code, referring to PythonWin and EditPadLight]

A lot of editors use the method of:

1. Select lines of text
2. Press TAB or SHIFT+TAB to change indentation out or in
respectively.

I dont know about those editors though.


This works for PythonWin, I don't know for EditPadLite. In IDLE (in
windows at least), the keypresses are ^[ and ^] for unindenting and
indenting, respectively; check the Edit menu for the actual shortcuts.

I just tried it in EditPad and PythonWin. It works in both. Thanks
guys, this is real handy to know.

David Lees
 
J

JanC

Christos "TZOTZIOY" Georgiou said:
This works for PythonWin

AFAIK PythonWin uses the Scintilla editor component?

This should (could?) work with all other Scintilla-based editors too:
SciTE, pyCrust, Eric3, Wing IDE, Boa Constructor, Black Adder, etc.
 
N

Neil Hodgson

JanC:
AFAIK PythonWin uses the Scintilla editor component?

Yes.
This should (could?) work with all other Scintilla-based editors too:
SciTE, pyCrust, Eric3, Wing IDE, Boa Constructor, Black Adder, etc.

This will work by default in Scintilla based editors. The container may
override the key binding which may happen when they emulate another editor
such as EMACS.

Neil
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,097
Messages
2,570,622
Members
47,235
Latest member
LuisaHamle

Latest Threads

Top