...
The second part it's about how under Vim it's possible to create some pre-packed files with some boring code and being able to just replace some key parts with some script, for example when creating a new C++ class I need the usual set of boring methods and ctors and the only thing that changes most of the time it's just the name of the class, so I would like to spend less time coding this repetitive portions of the code and kinda template and script the code generation for my source files
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).
After you edit your cpp file, are things set as you expect?
:verbose set formatprg? formatexpr? filetype? formatoptions?