仅当当前目录中存在 pom.xml 时,是否可以在 vim 中映射键?我知道当某个文件类型打开时可以映射键,但我不知道如何根据文件的存在来映射键。
我想为 vim 添加一些键绑定(bind)以帮助开发 maven 项目。例如,当我想浏览依赖的来源时:
mvn dependency:unpack-dependencies
-Dclassifier=sources
-Dmdep.failOnMissingClassifierArtifact=false
最佳答案
把这样的东西放到你的 vimrc 中:
function! IfPomXmlExists()
if file_readable("pom.xml")
" define your commands here..
map <buffer> <C-F9> :echo "hello pom!"<CR>
endif
endfunction
augroup pomxml
au!
autocmd BufReadPre * call IfPomXmlExists()
augroup END
关于maven - 当前目录中存在 pom.xml 时将键映射到命令?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7844737/