This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Programmation in python and indentation in editors

Tags: None
(comma "," separated)
User avatar
Dimitrios
Registered Member
Posts
659
Karma
0
OS
I am a little confused about the right indentation in python.
In kwrite, and in python scheme, when i press ENTER after a ':' it does an indentation. This is different with the indentation when i press on tab , and different with the indentation in vi editor.

What do you use as editor with python to have an homogenized indentation ?


«The magic continues...»
http://www.mageia.org
Image
User avatar
scummos
Global Moderator
Posts
1175
Karma
7
OS
For python, you should always use 4 space indentation. If you put this in the kate settings, it works very well. What's your problem more exactly?

Greetings


I'm working on the KDevelop IDE.
User avatar
Dimitrios
Registered Member
Posts
659
Karma
0
OS
The vi editor makes a tab of 10 columns when i press enter after the ":"
The kate editor make a tab of 4 columns
The tab with kate it is not a real tab. If i click on "del" at the beginning of the line it will not delete the space of the tab (4 columns) but one column at the time.
Instead the tab that i did in the vi editor, when i open the file in kate, i see a real tab. There is the » at the beginning of the line and if i press on "del" i can delete the whole tab (10 columns) and not only one column.

Image


«The magic continues...»
http://www.mageia.org
Image
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
Open Kate > Settings > Configure Kate > Editor Component > Editing. Select the "Indentation" tab. You probably have "Tabulators and Spaces" selected - and the "Tab width" and "Indentation width" will be set to different values - likely 10 and 4 respectively.

To fix this, simply set both to 4 characters.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
User avatar
scummos
Global Moderator
Posts
1175
Karma
7
OS
Yes. I also recommend setting indentation to "Spaces" instead of "Spaces and tabs", and reconfiguring vi so it indents with 4 spaces. This is an official python coding guideline (see "PEP 8").

To make kate unindent in the beginning of a line if you press backspace, activate the corresponding checkbox in Editing -> Indentation.

Greetings,
Sven


I'm working on the KDevelop IDE.
User avatar
Dimitrios
Registered Member
Posts
659
Karma
0
OS
Ok i did all the changes you suggested
Thanks very much both of you


«The magic continues...»
http://www.mageia.org
Image


Bookmarks



Who is online

Registered users: Bing [Bot], Evergrowing, Google [Bot], rockscient