Reputation: 65670
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?
Upvotes: 296
Views: 162317
Reputation: 829
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 .....
Upvotes: 2
Reputation: 1292
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
).
Upvotes: 69
Reputation: 439
Another way is to save session to a file and then edit this file as it contains all the mappings and settings.
:mks[ession] [file]
- Write a Vim script that restores the current editing
session.
Upvotes: 9
Reputation: 12970
: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.
Upvotes: 17
Reputation: 4326
:redir! > vim_keys.txt
:silent verbose map
:redir END
This outputs the shortcuts, with where they were defined, to a text file.
Upvotes: 142
Reputation: 5831
You can do that with the :map
command. There are also other variants.
:nmap
for normal mode mappings:vmap
for visual mode mappings:imap
for insert mode mappingsThe above list is not complete. Typing :help map
in Vim will give you more info.
Upvotes: 389
Reputation: 270775
Quite simply, just run the :map
variants with no arguments.
:map
:imap
:vmap
Upvotes: 19