保存.cpp文件时自动格式化vim中的代码

时间:2018-02-26 05:22:49

标签: c++ vim

我已阅读此How can I autoformat/indent C code in vim?有关如何格式化C / C ++代码的信息,但我希望在保存文件时自动编码代码,例如当vim-go调用gofmt时保存Golang代码。

如何配置我的vimrc?我使用了clang-format,并使用Vundle在spf13vim上安装了vim-clang-format

1 个答案:

答案 0 :(得分:2)

找到它。

  
      
  • g:clang_format#detect_style_file
  •   
     

当此变量的值为1时,vim-clang-format会自动检测样式文件,如.clang-format_clang-format,并将样式应用于格式化。

因此,此代码应位于.vimrc

let g:clang_format#auto_format=1
相关问题