Question

I'm using vim(7.3) with cscope in ubuntu. :cs find commands work fine, but I want to use some key bindings, so I download cscope_maps.vim and install it according to the tutorial here. However, no matter which place I put the vim file in, none of the key maps defined in the file work! For example I got one of the mapping as :

nmap <C-\>s :cs find s <C-R>=expand("<cword>")<CR><CR>

When I moved the cursor on a c symbol and pressed [CTRL]+[\]+s, nothing happened!

Does anyone know the reason and how to solve it?

Thanks.

Was it helpful?

Solution

Try to isolate the problem. First, while running vim, try something like

:nmap , :echo "hello"<CR>

and then type ,. Assuming that works, try the key combination you actually want, instead of ,. (When you write [CTRL]+[\]+s, you are using the CTRL and \ keys at the same time, right?) If that works, then try the actual cscope command from the tutorial.

Next, try adding a simple nmap command to your vimrc file. Does that work?

You should be able to load the script with

:source path/to/cscope_maps.vim

If that works, but simply dropping the file in your plugin directory did not, try

:set runtimepath?

to see which directories are being searched for plugins, and read

:help load-plugins

(Step 4 under :help startup) for other reasons they might not be loaded.

OTHER TIPS

I faced the same issue and following modification in cscope_maps.vim helped me to resolve this issue.

by default Cscope_maps.vim file provide following mapping

nmap <C-\>s :cs find s =expand("")
nmap <C-\>g :cs find g =expand("")
nmap <C-\>c :cs find c =expand("")
nmap <C-\>t :cs find t =expand("")
nmap <C-\>e :cs find e =expand("")
nmap <C-\>f :cs find f =expand("")
nmap <C-\>i :cs find i ^=expand("")$
nmap <C-\>d :cs find d =expand("")

as did not work for me in ubuntu 14.04 so i replaced <C-\> to z

nmap zs :cs find s =expand("")
nmap zg :cs find g =expand("")
nmap zc :cs find c =expand("")
nmap zt :cs find t =expand("")
nmap ze :cs find e =expand("")
nmap zf :cs find f =expand("")
nmap zi :cs find i ^=expand("")$
nmap zd :cs find d =expand("")

The Ctrl + s combination did not work for me on a Mac using VNC viewer. So I just replaced with some combination I wasn't using for anything else, like f + s etc.

The same thing happened to me. I figured there was an issue with the cscope_maps.vim because I had saved the html page instead of copying the contents of the page. This caused several obvious errors and even after correcting those initial errors it had changed the key mappings mentioned in the file according to the html scripts. Thus I would suggest just try copying the contents of the cscope_maps.vim from the link above in the file instead of downloading the webpage.

By default Vim will only wait 1 second for each keystroke in a mapping. It may be too short for these combination keys.

After I add following lines into vimrc, "CTRL + \" works.

set timeoutlen=4000 " in milliseconds
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top