vim+astyle安装使用

astyle下载安装

wget https://sourceforge.net/projects/astyle/files/astyle/astyle%203.1/astyle_3.1_linux.tar.gz
tar -zxvf astyle_3.1_linux.tar.gz
cd astyle/
cd build
cmake ..
make
make all
make install

配置环境

vim ~/.bashrc

将以下内容考入该文件

export PATH=$PATH:~/software/astyle/astyle/build/

使配置生效

source ~/.bashrc

打开.vimrc,将以下内容考进该文件

let g:formatdef_my_cpp = '"astyle --style=google"'
let g:formatters_cpp = ['my_cpp']
au BufWrite * :Autoformat

最后一行意味着退出文件就会自动保存,在写python文件时可能带来错误,因此可以只考前两行,使用时使用命令

astyle main.cpp

main.cpp是你要格式化的文件。

猜你喜欢

转载自www.cnblogs.com/qujingtongxiao/p/10201569.html