2014-07-16 26 views
0

(我已經發布了這個問題https://codereview.stackexchange.com/,標誌着偏離主題。主持人建議在SO張貼問題)如何使用`indent`程序在Linux

我使用indent我糾正命名塊縮進糾正縮進。一切都很好,除了名稱空間塊中的縮進。

我有樣本代碼:

$ cat test2.cc 
#include <iostream> 

namespace API 
{ 
void f() 
{ 
    std::cout << "f() called" << std::endl; 
} 
} 

但運行indent後,我得到了:

$ indent -st -bl -bli0 -i 4 -c 4 -kr -nce -bls test2.cc 
#include <iostream> 

namespace API 
{ 
    void f() 
^^^^<=== I don't want these indentation 
    { 
     std::cout << "f() called" << std::endl; 
    } 
} 

我不想命名塊和硬的第一縮進找到任何相關的縮進選項(這是非常複雜)。我如何解決這個問題?任何建議,將不勝感激。

回答

1

indent設計用於格式化C代碼。它並不真正瞭解C++語法,如namespace

我建議使用clang-format,這是一個C++格式化程序。

+0

謝謝你的建議。我會檢查'clang-format'。 –

相關問題