简体   繁体   中英

How remap default key in VIM, without affecting the other remap?

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 Co 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?

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 <Mo> 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM