3

I want to map Ctrl + mouse click to a command:

nnoremap <C-???> :YcmCompleter GoTo<CR>

Is it possible to do that using nnoremap? What symbol should I use for that?

2 Answers 2

4

You are looking for this which I found at the bottom of :h keycodes:

nnoremap <C-LeftMouse> :echom 'Foo'<CR>

And according to :h <LeftMouse> you also need to check that set mouse contains a or n

2
  • Thanks! It's working, I've read :h keycodes and h:mouse-using, but didn't find how to run command after mouse moved to new location, don't you know that? I.e. I ctrl+click some word, and vim move cursor to this word first and only then execute the command. Mouse mode is enabled in my .vimrc: set mouse=a
    – g4s8
    Jun 25, 2019 at 14:19
  • 1
    I don't think Vim has a way to detect a mouse button up event. I think you are either trying to do something vim can't do or you are overengineering what you want to do. You can ask another question describing exactly what you want to do and people should be able to help :)
    – statox
    Jun 25, 2019 at 14:23
0

This would work:

nnoremap <C-LeftMouse> <LeftMouse>:YcmCompleter GoTo<CR>

Add another <CR> at the end to go to the first result

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.