In my vimrc I call Uncrustify by this command:
%!uncrustify -l CPP -c D:\uncrustify\default.cfg
After that on some code I get a Windows Fatal error:
But when I call uncrustify on the same code in the console using the -f option, there is no error.
How can I change my vimrc to avoid such errors in the future? What can invoke this error?
In order to integrate Uncrustify with Vim properly, add the following to your
.vimrc
:Now you can either map this function (
Uncrustify
) to a combination of keys or you could do the convenient trick that I use. Create a file~/.vim/after/ftplugin/cpp.vim
where you can override any Vim settings particularly for C++ and add the following line there:This basically adds a pre-save hook. Now when you save the file with C++ code it will be automatically formatted by Uncrustify utilizing the configuration file you supplied earlier.
For example, the same could be done for Java: in
~/.vim/after/ftplugin/java.vim
add:You got the point.
NOTE: Everything presented here is well-tested and used every day by me.