cpp formatting tool - use clang-format in gvim on osx 10.11
fixing code format is trivial... why not use some automation tool?
$ brew update
$ brew install clang-format
$ wget https://llvm.org/svn/llvm-project/cfe/trunk/tools/clang-format/clang-format.py
# move this py script to some folder in your path, say, here: '/usr/share/scripts'
# follow this page, add two lines to .vimrc: http://clang.llvm.org/docs/ClangFormat.html
# put the following into ~/.clang-format
# how to use?
in gvim, open a cpp file, highlight some lines, eg.
5gg
5v
(now ctrl i)
$ brew update
$ brew install clang-format
$ wget https://llvm.org/svn/llvm-project/cfe/trunk/tools/clang-format/clang-format.py
# move this py script to some folder in your path, say, here: '/usr/share/scripts'
# follow this page, add two lines to .vimrc: http://clang.llvm.org/docs/ClangFormat.html
# put the following into ~/.clang-format
$ cat ~/.clang-format
BasedOnStyle: Google
AlignTrailingComments: true
AllowShortIfStatementsOnASingleLine: false
BreakBeforeBraces: Allman
ColumnLimit: 0
IndentWidth: 4
KeepEmptyLinesAtTheStartOfBlocks: true
Language: Cpp
MaxEmptyLinesToKeep: 4
ObjCSpaceAfterProperty: true
ObjCSpaceBeforeProtocolList: false
PointerBindsToType: false
SpacesBeforeTrailingComments: 1
TabWidth: 4
UseTab: Never
in gvim, open a cpp file, highlight some lines, eg.
5gg
5v
(now ctrl i)
Labels: clang-format, code formatting, cpp, gvim, osx
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home