gpt4 book ai didi

c++ - 准备 vim 环境以使用 clang-format

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:42:52 26 4
gpt4 key购买 nike

问题:

E319: Sorry, the command is not available in this version

问题
当我运行 vim 环境并尝试重新格式化代码 (CTRL+K) 时,我在屏幕上收到此警告

环境:
系统:Mac OS X

设置:
Vim :

VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Nov 17 2016 20:17:27)
MacOS X (unix) version
Included patches: 1-91

python :

python --version: Python 3.5.2

我做什么

谢谢,

最佳答案

解决方法:

1. 进入.vimrc 文件并添加命令

map <C-K> :pyf <path-to-this-file>/clang-format.py<cr>
imap <C-K><c-o>:pyf <path-to-this-file>/clang-format.py<cr>

2.添加这个https://llvm.org/svn/llvm-project/cfe/trunk/tools/clang-format/clang-format.py源代码到 clang-format.py 文件,你可以把这个文件保存到即

<path-to-this-file>/clang-format.py

其中 path-to-this-file 是您放置此文件的方向的路径。

3.保存clang-format.py文件并运行vim。检查命令是否有效。

您还可以为 OSX 安装 macvim。您可以在此处找到说明。 How can I install MacVim on OS X?

PS:如果您收到“抱歉,该命令在此版本中不可用”错误,请尝试:

map <C-K> :py3f <path-to-this-file>/clang-format.py<cr>
imap <C-K><c-o>:py3f <path-to-this-file>/clang-format.py<cr>

关于c++ - 准备 vim 环境以使用 clang-format,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40686684/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com