Slightly different

I’m using a slightly modified version of your section:

[Ruby]
Mimetypes=application/x-ruby
Section=Scripts
Variables=kate: indent-mode varindent; var-indent-indent-after ^( )*(if|while|def|class|for|unless).*|\\{[^\\}]*$|else|elsif|rescue|do|begin; var-indent-indent; var-indent-unindent ^( )*(end|else|elsif|rescue)|^[^\\{]*\\}; var-indent-triggerchars }def; space-indent on; indent-width 2;
Wildcards=*.rb

There’s mostly support for “unless” blocks and a slightly refined match for ending a block. Otherwise, e.g. “render” would match the unindent expression. It’s still necessary to have it match only full tokens, since e.g.

begin
  endowment

has “endowment” match unindent (it starts with “end”) and thus unintents the second line. I’m not quite sure what kind of regular expressions is used by kate, and also the unindentation triggers while you type, so there’s probably no way around it. (It would have to unindent after “end”, and then reindent once the token doesn’t match anymore.)

Otherwise, it works pretty well, but creates a spurious indentation level if you’re starting a block on the first line in the file. As long as the first line doesn’t match the indent-after expression, it’s fine. My personal guess is that this is due to a bug in kate.

Reply

  • You can use Markdown syntax to format and style the text.
  • You may link to images on this site using a special syntax
  • Web page addresses and e-mail addresses turn into links automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Copy the characters (respecting upper/lower case) from the image.