我基本上想让 vim
在 c++ 头文件上使用一个命令,并且只在 c++ 头文件上使用。我怎样才能做到这一点?
我已经尝试将命令放在 ~/.vim/ftplugin/hpp.vim
中,但没有用,因为 hpp 文件被 Vim 视为 cpp 文件。
最佳答案
在你的 ~/.vim/ftplugin/cpp.vim
中:
if expand('%:e') ==? 'hpp'
" your script here
endif
更好的是:
if expand('%:e') =~? '\v^h%(pp|h|\+\+|xx)?$'
" your script here
endif
关于c++ - 仅为 C++ header 设置 vim 文件类型脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32226834/