Thursday, November 29, 2012

Re: Indenting Based on Unbalanced Paranthesis

On Thursday, November 29, 2012 5:24:53 PM UTC-6, Danny Gratzer wrote:
> I am writing an indentation script for a simple language. The language is has very simple constructs and the indentation really only has 3 rules:
>
>
> 1. A comment has goes from a // until a newline, anything in a comment should be ignored.
>
>
>
> 2. If the line above contains a semi-colon, the indentation should be 0.
>
>
> 3. Otherwise, indent to 1 more than the most recent unbalanced ( and to 4 spaces if all paranthesis are balanced.
>
>
>
> The last rule is kinda stumping me, does anyone have any advice?
>
>

I'd try using the searchpair() or searchpairpos() functions for an exact solution which works in all cases.

Or a simpler solution might just check the previous line for an opening (, but this will be hard to get right for nested parentheses groups.

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments:

Post a Comment