I usually hop between files on my cscope-indexed codebase by using
:cscope find f <filename>
I'm trying to define a keyboard shortcut to prevent me having to type ":cscope find f" everytime. Pressing this shortcut would bring up an input prompt, to which I'll enter part of a filename in the cscope database. If there are multiple files, it would show up the list of files, from which I can select the file I want to go to. I've got to this much so far, but since I'm not at all proficient with VIM scripting, I'm unable to complete it. (what I've coded so far is taken from another question, thanks to Eelvex) .
Could someone correct the below script for me ? I'm getting numerous errors while I try to use this shortcut
function! GetPat()
call inputsave()
let filename = input("Enter filename: ")
call inputrestore()
return filename
endfunction
map ` :cscope find f '.GetPat().'<CR>
The mapping won't wait for you to enter the input and then continue. Also, the mapping is wrong, remember that mappings work as if you typed the text, you might get away with something like that using (not tested):
But why not just:
That would leave you after the last space ready to enter your pattern and just hit enter.