[nvim] Add function to show all keymappings
Use :ShowMaps to display all currently mapped things for vim. Will not include things like `i`, but actual mappings.
This commit is contained in:
parent
48be54b79c
commit
350158c520
1 changed files with 20 additions and 0 deletions
|
@ -436,6 +436,26 @@ au BufNewFile,BufRead /dev/shm/gopass.* setlocal noswapfile nobackup noundofile
|
||||||
" KEYBINDINGS {{{
|
" KEYBINDINGS {{{
|
||||||
" ================================================================================
|
" ================================================================================
|
||||||
"
|
"
|
||||||
|
" Show all mapped keys in a list - from https://stackoverflow.com/questions/13990136/display-a-ordered-vim-keyboard-mapping
|
||||||
|
function! s:ShowMaps()
|
||||||
|
let old_reg = getreg("a") " save the current content of register a
|
||||||
|
let old_reg_type = getregtype("a") " save the type of the register as well
|
||||||
|
try
|
||||||
|
redir @a " redirect output to register a
|
||||||
|
" Get the list of all key mappings silently, satisfy "Press ENTER to continue"
|
||||||
|
silent map | call feedkeys("\<CR>")
|
||||||
|
redir END " end output redirection
|
||||||
|
vnew " new buffer in vertical window
|
||||||
|
put a " put content of register
|
||||||
|
" Sort on 4th character column which is the key(s)
|
||||||
|
%!sort -k1.4,1.4
|
||||||
|
finally " Execute even if exception is raised
|
||||||
|
call setreg("a", old_reg, old_reg_type) " restore register a
|
||||||
|
endtry
|
||||||
|
endfunction
|
||||||
|
" use :ShowMaps to call the function
|
||||||
|
com! ShowMaps call s:ShowMaps() " Enable :ShowMaps to call the function
|
||||||
|
|
||||||
" set our leader key to space since with hjkl, space is largely useless
|
" set our leader key to space since with hjkl, space is largely useless
|
||||||
let mapleader = "\<Space>"
|
let mapleader = "\<Space>"
|
||||||
" maps the leader for buffer local mappings (e.g. vim-waikiki for files under
|
" maps the leader for buffer local mappings (e.g. vim-waikiki for files under
|
||||||
|
|
Loading…
Reference in a new issue