Basically, I'd like to view all of the keys maps made in the current buffer by all of plugins, vimrc, etc, in the current buffer. Is there anyway to do this?
7 Answers
You can do that with the :map command. There are also other variants.
:nmapfor normal mode mappings:vmapfor visual mode mappings:imapfor insert mode mappings
The above list is not complete. Typing :help map in Vim will give you more info.
8 Comments
:map, as the original question asks, just shows mappings made by plugins, vimrc, etc. If you want to see the default key bindings in vim, use :index:help index.grep or search (/) on their output?:redir! > vim_keys.txt :silent verbose map :redir END This outputs the shortcuts, with where they were defined, to a text file.
4 Comments
:redir command, not the :remap command.vim_keys.txt file is located in working directory which can be checked by running :pwd.look like this, or ideally, submit a separate answer, so you'll get some credit as well? Cheers.In addition to answers about :map with no arguments: do not miss its verbose form (:verbose map) which shows where the mapping(s) was defined (see :help map-verbose).
1 Comment
:map and its friends are the key, :verbose adds info and :redir allow post-search refinement.
They are a perfect mix to show what command is bind to what shortcut and viceversa, but if you want to search some keys and avoid temp files whenever you need to search mappings, take a look to scriptease and :Verbose command.
It is a wrapper on :verbose to show result in a preview window.
this way you can search whatever you want inside results without using temp files
type :Verbose map and use / ? as usual.
Comments
Install this plug like this:
Plug 'https://github.com/tpope/vim-scriptease'What to know what
<M-C-F10>(my own mapping) does? try this
:Verbose nmap <M-C-F10> | omap <M-C-F10> | vmap <M-C-F10> | imap <M-C-F10> | cmap <M-C-F10> | tmap <M-C-F10> put it in a function:
func! Leo_keymap(keys) exe "verbose map " . a:keys exe "verbose map! " . a:keys exe "verbose tmap " . a:keys " 不好 / not good: " exe "verbose nmap " . a:keys " exe "verbose omap " . a:keys " exe "verbose vmap " . a:keys " exe "verbose imap " . a:keys " exe "verbose cmap " . a:keys " exe "verbose tmap " . a:keys " 不行 / not work " exe "Verbose map " . a:keys . <Bar> . "verbose map! " . a:keys . <Bar> . "verbose tmap " . a:keys endfunc cnoreabbrev <expr> map getcmdtype() == ":" && getcmdline() == 'map' ? 'Verbose call Leo_keymap("")<left><left>' : 'map' " 不行 / not work " command! -nargs=* Map :new<CR>:put = Vim_out('call Leo_keymap(input())') " 不行 / not work " :put = Vim_out("call Leo_keymap('ls')") " may be take placed by the above line cnoreabbrev <expr> nmap getcmdtype() == ":" && getcmdline() == 'nmap' ? 'Verbose map' : 'map' cnoreabbrev <expr> imap getcmdtype() == ":" && getcmdline() == 'imap' ? 'Verbose imap' : 'imap' cnoreabbrev <expr> cmap getcmdtype() == ":" && getcmdline() == 'cmap' ? 'Verbose cmap' : 'cmap' cnoreabbrev <expr> tmap getcmdtype() == ":" && getcmdline() == 'tmap' ? 'Verbose tmap' : 'tmap' old content, may be useless:
func! Leo_keymap(keys) exe "verbose map " . a:keys exe "verbose map! " . a:keys exe "verbose tmap " . a:keys " exe "Verbose map " . a:keys . <Bar> . "verbose map! " . a:keys . <Bar> . "verbose tmap " . a:keys " exe "verbose nmap " . a:keys " exe "verbose omap " . a:keys " exe "verbose vmap " . a:keys " exe "verbose imap " . a:keys " exe "verbose cmap " . a:keys " exe "verbose tmap " . a:keys endfunc command! -nargs=* Map :call Leo_keymap(<q-args>) now :Map d gets:
n dL * v$hhd Last set from ~/dotF/cfg/nvim/plug_wf.vim line 712 n df * ggdG Last set from ~/dotF/cfg/nvim/clipboard_regis.vim line 250 n dB * %dab Last set from ~/dotF/cfg/nvim/clipboard_regis.vim line 230 n d" * da" Last set from ~/dotF/cfg/nvim/clipboard_regis.vim line 212 n dw * diw Last set from ~/dotF/cfg/nvim/clipboard_regis.vim line 211 n d' * :call DoubleAsSingle()<CR>da' Last set from ~/dotF/cfg/nvim/clipboard_regis.vim line 195 No mapping found No mapping found Press ENTER or type command to continue So far, I don't know how to combine this with :Verbose .....
:help indexto see the VIM's default key bindings. (Credit to Von and Lqueryvg):Telescope keymapsto view/fuzzy search them. Or if you use whichkey you can navigate keymaps through a menu.