我知道如何使用CtrlP。我输入ctrl+p,然后开始输入文件名等等。但是,作为一个非常懒的开发者,我希望能够直接发送当前单词到CtrlP。我知道如何获取当前单词:
let l:currentWord = expand('<cword>')
在Vim语言中,我如何将l:currentWord发送到CtrlP?
map <F6> :call ComposerKnowWhereCurrentFileIs()<CR>
function! ComposerKnowWhereCurrentFileIs()
let l:currentWord = expand('<cword>')
let l:command = "grep " . l:currentWord . " ../path/to/composer -R | awk '{print $6}' | awk -F\\' '{print $2}'"
let l:commandFileFound = l:command . ' | wc -l'
let l:numberOfResults = system(l:commandFileFound)
if l:numberOfResults == 1
let l:fileName = system(l:command)
let l:openFileCommand = 'tabe /path/to/project' . l:fileName
exec l:openFileCommand
else
echo "Too many files :-( - use CtrlP ;-) "
endif
endfunction