在CLion中使用clang-format [英] Using clang-format in CLion

查看:5238
本文介绍了在CLion中使用clang-format的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在CLION中使用clang-format格式化我的代码。我已经经历了设置,没有找到任何设置,将允许我运行外部命令来转换代码。

解决方案

您可以在CLion中使用外部工具 / p>

转到文件 - >设置 - >工具 - >外部工具,然后单击加号。



会弹出一个窗口。使用您选择的名称。



对于工具设置选项卡我使用此配置:




  • 计划: clang-format-3.7 可执行)


  • 参数: -i $ FileName $


  • 工作目录: $ FileDir $




现在,当你的文件打开,你可以去 Tools->外部工具并运行上面的配置。它基本上调用 clang-format 并执行inplace格式化。



您也可以设置一个自定义键盘映射,工具。


I'd like to format my code using clang-format in CLion. I've gone through the settings and haven't found any setting that would allow me to run an external command to transform code. How are such things normally done in CLion?

解决方案

You can use External Tools in CLion.

Go to File->Settings->Tools->External Tools and click on the plus sign.

A window should pop up. Use a name of your choice.

For the Tool settings tab I'm using this configuration:

  • Program: clang-format-3.7 (you should use the name of your executable here)

  • Parameters: -i $FileName$

  • Working directory: $FileDir$

Now, with your file open, you can go to Tools->External tools and run the config above. It basically calls clang-format and does inplace formatting.

You can also set a custom keymap to it, just search the name of your external tool in the Settings menu.

这篇关于在CLion中使用clang-format的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆