Linux环境vscode clang-format格式化:vscode clang format command is not available亲测有效!

文章讲述了在VSCode中安装并配置clang-format插件时遇到的错误,原因在于设置中的工具路径不正确。作者提供了亲测有效的解决方案,即确认本地安装了clang-format工具,找到其正确路径(如/usr/lib/llvm-13/bin/clang-format),并在VSCode设置中更新插件执行文件路径。
摘要由CSDN通过智能技术生成

问题现象

vscode安装了clang-format插件,但是使用就报错
格式化报错

问题原因

设置中配置的clang-format插件工具路径不正确。

解决方案-亲测有效!

  1. 确认本地安装了clang-format工具:终端输入clang-format(也可能是clang-format-13等版本,建议tab自动补全一下),如果没有,安装提示安装
    在这里插入图片描述
  2. 我的本地安装的是clang-format-13,查看路径在/usr/lib/llvm-13/bin/clang-format
Zhenxing.Wang3@123:~/data/my_code$ whereis clang-format-13
clang-format-13: /usr/bin/clang-format-13 /usr/share/man/man1/clang-format-13.1.gz
Zhenxing.Wang3@123:~/data/my_code$ cd /usr/bin/
Zhenxing.Wang3@123:/usr/bin$ ll |grep clang
lrwxrwxrwx  1 root           root                 31 Jul  6  2022 clang-format-13 -> ../lib/llvm-13/bin/clang-format*
-rwxr-xr-x  1 root           root               5129 Jul  6  2022 clang-format-diff-13*
lrwxrwxrwx  1 root           root                 35 Jul  6  2022 git-clang-format-13 -> ../lib/llvm-13/bin/git-clang-format*
  1. ctrl+, 打开设置选项,搜索format,将clang-format.executable值设置为刚刚找到的路径即可
    在这里插入图片描述
  • 8
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值