Auto Indentation for Python

Here’s my preliminary idea for the auto indentation for Python in Anjuta.
[code lang=”c”]
/* When a new line character is inserted (user pressed Return after a line),
* the following pseudo code could be executed. Here currentline is
* the line number of the present line (after which the new line is
* supposed to begin.
* Assumption: Ignoring multilines for now.
*/

if (there is a colon at the end of currentline)
{
line_indent = get_indentation (currentline) + INDENT_SIZE;
}
else
{
line = currentline;
while (line is a blank or spaces-only line)
line–;
line_indent = get_indentation (line);
}
return line_indent;
[/code]
I am thinking of coding this approach, testing and improving. I know this is too naive, but I just want to start with something. The multilines and other special cases that follow thereafter would provide for further tweaking. This whole project seems like a nice TopCoder Marathon Match, where the first submission is always a naive solution, and things improve over successive submissions. Would be nice to follow the “commit early, commit often” theory during this GSoC 🙂

19,272 thoughts on “Auto Indentation for Python

  1. It is the best time to make a few plans for the longer term and it’s time
    to be happy. I’ve learn this publish and if I could I desire to suggest you few
    attention-grabbing issues or suggestions. Maybe you could write subsequent articles relating
    to this article. I want to read even more issues approximately it!

Leave a Reply

Your email address will not be published. Required fields are marked *

301 Moved Permanently

Moved Permanently

The document has moved here.