On Fri, 27 Aug 2004, Gavin Henry wrote:
Last question,
Do you need to press any keys to indent?
Well, "enter", I suppose.
The behavior I see is that Vim will preserve the indentation level of the previous line of code, unless it detects a left brace (which denotes a new block of code and so is indented) or a right brace (which drops back to the previous level of indentation).
As near as I can tell, the indentation engine does something like:
s/{\s*\n/{\s*\n /
Which is to say, if a line ends with a left-brace (and any whitespace), the next line will be automatically idented to the set tab width.
If you enter a right-brace character, the editor will drop back to the level that the previous left-brace delimited block started from, e.g.
$foo = qq{ whatever # Vim auto-adds $tab-width spaces here whatever else # Vim auto-indents this line to match the above } # <-- this character slides back immediately
$bar =qq{ manual-ident # I manually incresed the indent level here auto-indent # Vim preserves the last level again { ... } # self-contained braces; no indent change } # Vim drops back all the way to the level of the last open "{"
For me, this only works with braces, and the general set of balanced bracket characters. I tend to do a lot of --
$foo = qq[ whatever multi-line thing ];
-- where, just to keep Different Things Different (e.g. double-quoted strings are not the same as code blocks), I deliberately don't use braces. The price for this is that Vim doesn't increase the indentation for me automatically, so I have to get that myself.
But I can live with that.
Vim ain't perfect, but at least it isn't Emacs :-)
-- Chris Devers
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>