Linux环境vscode clang-format格式化:vscode clang format command is not available

问题现象

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
bash 复制代码
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 值设置为刚刚找到的路径即可
相关推荐
orion5720 小时前
Missing Semester Class1:course overview and introduction of shell
linux
apocelipes1 天前
常用编程语言和库的正则表达式性能对比
c语言·c++·python·性能优化·golang·开发工具和环境
用户120487221611 天前
Linux驱动编译与加载
linux·嵌入式
用户805533698031 天前
Input 子系统架构:Core、Handler、Driver 三层是怎么协作的
linux·嵌入式
用户805533698031 天前
RK-Forge外设系列开篇 - 把板子从「能启动」变成「能用」:Ethernet/SPI/MMC 三个纯接线外设
linux·github·嵌入式
七歌杜金房2 天前
我终于又有了自己的 Linux 电脑
linux·debian·mac
郝学胜_神的一滴2 天前
CMake 034:生成器表达式:解耦构建时序、精简分支逻辑的终极利器
c++·cmake
tntxia3 天前
linux curl命令详解_curl详解
linux
扛枪的书生3 天前
Linux 网络管理器用法速查
linux
见过夏天3 天前
C++ 基础入门完全指南
c++