Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim auto indent private keyword

Tags:

c++

vim

I'm learning Vim (I'm using gVim)
I need to do the following: Suppose I typed this:

class MyClass {
    private
}

After typing the : after private, result should be:

class MyClass {
private:
}

How can I do automate that behaviour?
I tried with

:imap private: <Home><Delete>

But I feel it's not an elegant solution at all. I already installed c.vim by Fritz Mehner.

like image 969
erandros Avatar asked Dec 07 '22 19:12

erandros


1 Answers

set cindent
set cinoptions=g-1

Reference: http://vimdoc.sourceforge.net/htmldoc/indent.html

like image 125
Matvey Aksenov Avatar answered Dec 20 '22 07:12

Matvey Aksenov