Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

gabor (1626)

  (email not shown publicly)

Perl developer and trainer []
Test automation using Perl []

Journal of gabor (1626)

Wednesday November 12, 2008
02:12 AM

Auto-indentation, type ahead

[ #37862 ]
I was trying to improve the auto-indentation of Padre.
  1. First it had no auto-indentation at all.
  2. Then it would copy the indentation from the previous line every time you press ENTER.
  3. Then people asked that it will add another level of indentation if there is an opening brace { on the line where the ENTER was pressed.

So far it is working and you can pick one of the 3 options. Though I just remembered I still have to allow the user to decide if the indentation is TAB or N spaces and what is N.

Anyway, I did not really like option 3 as I am used to type the closing brace } quickly after the ENTER which reminded me that some people like that - what's its name, type-ahead? - feature where their editor guesses what they want to write and adds that part too. For example if I type { it will add two newlines and a } on the second one indented to the level where it should be. Moving the cursor to the line between the two where you should start typing the content of the block.

I wonder, is the auto-indentation just a special case of this type-ahead feature?

In addition, looking at vi I noticed it has this feature of dealing with indentation when you type the closing brace yourself. If you do that on the beginning of a line it can auto indent it to where it should be.

Of course there might be several answers to the question where should the opening and closing braces be? and probably every developer has her own preference of exactly what she wants to be typed ahead.

I guess I need to look at how other editors and IDEs provide this feature and listen to the potential users. That's you.

As a side note I am going to talk about Padre and wxPerl development in Haifa next week.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • In vim, when you enter a new line, the cursor is positioned according to the indentation level it should be, but no characters are actually entered. That is, if you use the cursor keys to leave the line and then come back to it, you will find that the line is empty. Only as soon as you type your first character do the indentation characters materialise.