Closed. This question needs to be more focused。它当前不接受答案。
                            
                        
                    
                
                            
                                
                
                        
                            
                        
                    
                        
                            想改善这个问题吗?更新问题,使其仅通过editing this post专注于一个问题。
                        
                        2年前关闭。
                                                                                            
                
        
我有很多不缩进的C / C ++源文件。我想以编程方式美化它们。我该如何实现?

最佳答案

编写一个Python脚本,以调用诸如Artistic Style之类的C ++美化器。

http://astyle.sourceforge.net/

这是您的python脚本的外观:

# Collect all the files you need to beautify in "files"

#Loop through each C/C++ file
for file in files:
    command = "astyle " + file
    import subprocess
    process = subprocess.Popen(command.split(), stdout=subprocess.PIPE)
    output, error = process.communicate()


艺术风格的示例用法是:

astyle example.cpp


要么

astyle --style=ansi --indent=tab example.cpp

08-19 13:28