Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to modify the cindent rules for one case in vim?

Tags:

vim

indentation

d

I am currently using vim as my editor for programming in D. The indent rules are pretty much identical to C, but I've run into a case that vim doesn't handle by default. In D, case statements can take strings which are not properly handled by cindent.

For instance, this works:

switch(blah)
{
case 1:
    // something
case some_variable:
    // ...
}

But not this:

switch(blah)
{
    case "yark":
        case "flurb":
    // something
    case "...":
        // ...
}

Is there some way to override that single rule in a custom indent file, or would the entire cindent ruleset have to be reimplemented?

like image 433
Dave B Avatar asked Oct 15 '22 02:10

Dave B


1 Answers

Try Vim 7.3. The indentation rules introduced in this version mainly for JavaScript also fix this particular situation.

With Vim 7.3 the code is correctly indented as:

switch(blah)
{
    case "yark":
    case "flurb":
        // something
    case "...":
        // ...
}
like image 189
richq Avatar answered Oct 18 '22 14:10

richq