Wednesday, May 22, 2013

Re: How to get Allman style while typing and templated C++ code in Vim 7.3

On Wednesday, May 22, 2013 10:43:48 AM UTC-5, arj...@gmail.com wrote:
> Hi guys, my first post here and this is my 3rd day with vim.
>

Welcome!

>
> I'm used to astyle ( http://astyle.sourceforge.net/ ) and I like the Allman style and I would love the ability to get some smart formatting while typing C++ code

It looks from the description of astyle, that you should just be able to use astyle still, automatically as you type in Vim.

See :help 'formatprg' and :help 'formatoptions'.

> My actual .vimrc is this one
> ...
> syntax on
> ...
> set autoindent smartindent " auto/smart indent
> ...
> set autoindent
> set cindent

You have autoindent turned on twice, and smartindent (which I would recommend NOT using, it's not smart at all), and also cindent. cindent will override all the previous ones.

Additionally, normally you don't turn cindent on in your .vimrc.

Instead, right before your "syntax on" command, put:

filetype indent on

or

filetype plugin indent on

This will turn on Vim's smart filetype-based indenting.

If you want to use astyle you may not want to put the "indent" in there however, or you could override it for C/C++ code using the "after" directory (:help after-directory).

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments: