1

Working on a C file, Vim correctly indents as I type. In Objective-C, however, it gets indentation right, but deindentation wrong for instance methods, unless I exit insert mode and use the = operator.

For example, if | is the cursor, in C I get:

int main()|

hit Enter

int main()
    |

type {

int main()
{|

hit Enter

int main()
{
    |

type }

int main()
{
}|

But in Objective-C, I get:

- (void)method
{|

hit Enter

- (void)method
{
    |

type }

- (void)method
{
    }

I have 'autoindent' on, 'smartindent' off, 'cindent' on, and 'cinkeys' is 0{,0},0),:,0#,!^F,o,O,e

  • smartindent talks about it. Maybe you have an autocomand that turns on cindent when in a .c file so It doesn't work for your objective C files? I think if you turn smartindent on it should work. From :h smartindent: "When typing '}' as the first character in a new line, that line is given the same indent as the matching '{'." – Tumbler41 Jul 13 '16 at 21:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.