Code formatting,

16 views
Skip to first unread message

Lukasz Kaczmraczyk

unread,
Oct 22, 2017, 5:10:09 AM10/22/17
to mofem Group
Hello All,

In Atom.io and VS Code we can use clang-format https://clang.llvm.org/docs/index.html. This is code for formatting C++.

I had been using auto indentation from VIM, which a bit of my style, which I very compact, but not necessarily readable.  A better solution is to use some standard and well thought style, which is familiar to others. For newly created code, we can agree that we will use LLVM format style. LLVM is one the most popular formatting styles, and can be used easily set up in atom, VS code and many other editors. Editors using clang-fromat by packages or extensions.

How to set-up VS-code:
Install the clang-format extension and set LLVM style by adding line to users configuration,
"C_Cpp.clang_format_fallbackStyle": "LLVM"

To format code Shift + Option +F on mac, on Ctr + Chift +I on Ubuntu and Shift + Alt + F on Windows. I using VIM keyboard map, and use "=" key to format code.

How to set-up Atom.io:
Install clang-format package.  To format code, you press Shift-Cmd + K. 

If you using VIM key-map, you can add your clang-format kay map, i.e. 
'atom-text-editor':
 
'=': 'clang-format:format'

From now on we could agree that only clang-formatted code with LLVM style is accepted in pull requests.

Kind regards,
Lukasz
Reply all
Reply to author
Forward
0 new messages