vim c++ 代码自动格式化配置

2019-11-13


1
2
3
4
5
6
7
mkdir /work/soft/astyle
wget https://jaist.dl.sourceforge.net/project/astyle/astyle/astyle%203.1/astyle_3.1_linux.tar.gz
tar zxvf astyle_3.1_linux.tar.gz
cd /work/soft/astyle/astyle/build/gcc
make
cd ../bin
cp astyle /usr/bin/astyle
  • 配置 vim 配置文件 .vimrc
1
2
3
let g:formatdef_my_cpp = '"astyle --style=attach --pad-oper --lineend=linux"'
let g:formatters_cpp = ['my_cpp']
au BufWrite * :Autoformat