Question

So, I have the following keymap in my .vimrc

noremap <C-o> :browse confirm e<CR>
vnoremap <C-o> :browse confirm e<CR>
inoremap <C-o> :browse confirm e<CR>

This is for the GUI of GVIM. Then I will get a popup with file folder. Here I can select files.

But this disables the Control-o file jump (when you press Ctrl-o). I don't want that, but I want to hold the Ctrl-o map for the GUI folder view. I still want use the folder jump.

So, I thought i could map the jump one file back from Control-o C-o to Alt-o. So the map would look like noremap :jump 1g back in history, or something.

I tried everything, to see what the default command was when you give the Control-o key for jumping back in the file history. I don't know how you see the default command for the standard Control-o .

The :verbose map is only applicable for remapped keys.

Anyone have suggestions to find the right command for the default Control-o key?

Was it helpful?

Solution

Some other programs have the concept of "key bindings" where there is a list of available internal commands, and then various keys are assigned to trigger these commands. Vim does not work that way. There is no spoon internal command triggered by CTRL-O. What you can do is map ALT-o to CTRL-O.

I am not sure that <M-o> works for ALT-o on my system, but for the sake of discussion, let's assume that it does on yours. If you were to define

:nnoremap <C-o> :browse confirm e<CR>
:nmap <M-o> <C-O>

Then ALT-o would have the same effect as :browse confirm e<CR>. But you are already using the "nore" variant, so what you are more likely to do is

:nnoremap <C-o> :browse confirm e<CR>
:nnoremap <M-o> <C-O>

and this would make ALT-o behave like an unmapped CTRL-O.

Unless you have a :cmap that affects browse confirm e<CR>, or you are one of those people who remap :, then it does not matter whether you use :nmap or :nnoremap in the first line above.

:help :noremap
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top