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 值设置为刚刚找到的路径即可
相关推荐
Java.熵减码农3 小时前
解决Linux修改环境变量后导致登录循环进不去系统的问题
linux·运维·服务器
txinyu的博客3 小时前
解析业务层的key冲突问题
开发语言·c++·分布式
天骄t3 小时前
嵌入式系统与51单片机核心原理
linux·单片机·51单片机
阿部多瑞 ABU4 小时前
`chenmo` —— 可编程元叙事引擎 V2.3+
linux·人工智能·python·ai写作
acanab4 小时前
VScode python插件
ide·vscode·python
SmartRadio4 小时前
ESP32添加修改蓝牙名称和获取蓝牙连接状态的AT命令-完整UART BLE服务功能后的完整`main.c`代码
c语言·开发语言·c++·esp32·ble
徐同保4 小时前
nginx转发,指向一个可以正常访问的网站
linux·服务器·nginx
HIT_Weston4 小时前
95、【Ubuntu】【Hugo】搭建私人博客:_default&partials
linux·运维·ubuntu
实心儿儿5 小时前
Linux —— 基础开发工具5
linux·运维·算法
oMcLin5 小时前
如何在SUSE Linux Enterprise Server 15 SP4上通过配置并优化ZFS存储池,提升文件存储与数据备份的效率?
java·linux·运维