Autoformatting

Post any comments, suggestions, annoyances or ideas for future releases here. Please do not post bug reports or questions here.
Post Reply
Endymion
Posts: 9
Joined: Mon Feb 06, 2012 7:50 am

Autoformatting

Post by Endymion »

I saw the best decision in the jEdit editor. Any line, matching to own regular expression, automatically receives indentation. Unfortunately, even coders of this fine editor didn't finish thinking about this clever thought up to the end. It would be logical to add expression for a ledge also. Here is how it could look.

[Indent]
\s*(if|elsif)\s+.+\s+then
\s*else
\s*(while|for)\s+.+\s*do
.*(procedure|function)\s+.+\(.*\))\s*

[Ledge]
\s*end\s(if|while|for|procedure|function)

Result is formatting on-the-fly:

Code: Select all

export function permute3(sequence x)
  sequence AllPermutations = {}
  integer Quantity = length(x)
  sequence CurrentPermutation
  for i = 1 to Quantity do
    for j = 1 to Quantity do
      if i != j then
        for k = 1 to Quantity do
          if k != i and k != j then
            CurrentPermutation = x[i] & x[j] & x[k]
            AllPermutations = append(AllPermutations, CurrentPermutation)
          end if
        end for
      end if
    end for
  end for
  return AllPermutations
end function
Post Reply