Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ Commands
| `:Commits` | Git commits (requires [fugitive.vim][f]) |
| `:BCommits` | Git commits for the current buffer; visual-select lines to track changes in the range |
| `:Commands` | Commands |
| `:Maps` | Normal mode mappings |
| `:Maps` | All mode mappings |
| `:Helptags` | Help tags <sup id="a1">[1](#helptags)</sup> |
| `:Filetypes` | File types

Expand Down Expand Up @@ -299,6 +299,7 @@ Mappings

| Mapping | Description |
| --- | --- |
| `<plug>(fzf-maps)` | All mode mappings |
| `<plug>(fzf-maps-n)` | Normal mode mappings |
| `<plug>(fzf-maps-i)` | Insert mode mappings |
| `<plug>(fzf-maps-x)` | Visual mode mappings |
Expand All @@ -315,6 +316,12 @@ nmap <leader><tab> <plug>(fzf-maps-n)
xmap <leader><tab> <plug>(fzf-maps-x)
omap <leader><tab> <plug>(fzf-maps-o)

" Or, to get all mapping from any mode
map <leader><leader><tab> <plug>(fzf-maps)
map! <leader><leader><tab> <plug>(fzf-maps)
tmap <leader><leader><tab> <plug>(fzf-maps)
lmap <leader><leader><tab> <plug>(fzf-maps)

" Insert mode completion
imap <c-x><c-k> <plug>(fzf-complete-word)
imap <c-x><c-f> <plug>(fzf-complete-path)
Expand Down
36 changes: 23 additions & 13 deletions autoload/fzf/vim.vim
Original file line number Diff line number Diff line change
Expand Up @@ -1270,13 +1270,13 @@ function! s:align_pairs(list)
let maxlen = 0
let pairs = []
for elem in a:list
let match = matchlist(elem, '^\(\S*\)\s*\(.*\)$')
let [_, k, v] = match[0:2]
let maxlen = max([maxlen, len(k)])
call add(pairs, [k, substitute(v, '^\*\?[@ ]\?', '', '')])
let match = matchlist(elem, '^\(\w\)\?\s*\(\S*\)\s*\(.*\)$')
let [_, m, k, v] = match[0:3]
let maxlen = max([maxlen, len(m) + len(k)])
call add(pairs, [m, k, substitute(v, '^\*\?[@ ]\?', '', '')])
endfor
let maxlen = min([maxlen, 35])
return map(pairs, "printf('%-'.maxlen.'s', v:val[0]).' '.v:val[1]")
let maxlen = min([maxlen, 38])
return map(pairs, "(v:val[0] != \"\"?v:val[0]:\" \").' '.printf('%-'.maxlen.'s', v:val[1]).' '.v:val[2]")
endfunction

function! s:highlight_keys(str)
Expand All @@ -1293,15 +1293,24 @@ function! s:key_sink(line)
\ substitute(key, '<[^ >]\+>', '\=eval("\"\\".submatch(0)."\"")', 'g'))
endfunction

function! fzf#vim#maps(mode, ...)
function! fzf#vim#maps(mode='*', ...)
let s:map_gv = a:mode == 'x' ? 'gv' : ''
let s:map_cnt = v:count == 0 ? '' : v:count
let s:map_reg = empty(v:register) ? '' : ('"'.v:register)
let s:map_op = a:mode == 'o' ? v:operator : ''

redir => cout
silent execute 'verbose' a:mode.'map'
redir END
let l:cout = ''
if a:mode == '*'
for l:map in ['map', 'map!', 'tmap', 'lmap']
redir =>> cout
silent execute 'verbose ' . l:map
redir END
endfor
else
redir => cout
silent execute 'verbose' a:mode.'map'
redir END
endif
let list = []
let curr = ''
for line in split(cout, "\n")
Expand All @@ -1310,13 +1319,14 @@ function! fzf#vim#maps(mode, ...)
call add(list, printf('%s %s', curr, s:green(src, 'Comment')))
let curr = ''
else
if !empty(curr)
if !empty(curr) && curr !~ ".*No mapping.*"
call add(list, curr)
endif
let curr = line[3:]
" let curr = line[3:]
let curr = line
endif
endfor
if !empty(curr)
if !empty(curr) && curr !~ ".*No mapping.*"
call add(list, curr)
endif
let aligned = s:align_pairs(list)
Expand Down
9 changes: 8 additions & 1 deletion doc/fzf-vim.txt
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ COMMANDS *fzf-vim-commands*
`:Commits` | Git commits (requires {fugitive.vim}{10})
`:BCommits` | Git commits for the current buffer; visual-select lines to track changes in the range
`:Commands` | Commands
`:Maps` | Normal mode mappings
`:Maps` | All mode mappings
`:Helptags` | Help tags [1]
`:Filetypes` | File types
------------------+-----------------------------------------------------------------------
Expand Down Expand Up @@ -369,6 +369,7 @@ MAPPINGS *fzf-vim-mappings*
---------------------------------+------------------------------------------
Mapping | Description ~
---------------------------------+------------------------------------------
<plug>(fzf-maps) | All mode mappings
<plug>(fzf-maps-n) | Normal mode mappings
<plug>(fzf-maps-i) | Insert mode mappings
<plug>(fzf-maps-x) | Visual mode mappings
Expand All @@ -385,6 +386,12 @@ MAPPINGS *fzf-vim-mappings*
xmap <leader><tab> <plug>(fzf-maps-x)
omap <leader><tab> <plug>(fzf-maps-o)

" Or, to get all mapping from any mode
map <leader><leader><tab> <plug>(fzf-maps)
map! <leader><leader><tab> <plug>(fzf-maps)
tmap <leader><leader><tab> <plug>(fzf-maps)
lmap <leader><leader><tab> <plug>(fzf-maps)

" Insert mode completion
imap <c-x><c-k> <plug>(fzf-complete-word)
imap <c-x><c-f> <plug>(fzf-complete-path)
Expand Down
2 changes: 1 addition & 1 deletion plugin/fzf.vim
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ call s:defs([
\'command! -bar -bang Windows call fzf#vim#windows(<bang>0)',
\'command! -bar -bang -range=% Commits let b:fzf_winview = winsaveview() | <line1>,<line2>call fzf#vim#commits(fzf#vim#with_preview({ "placeholder": "" }), <bang>0)',
\'command! -bar -bang -range=% BCommits let b:fzf_winview = winsaveview() | <line1>,<line2>call fzf#vim#buffer_commits(fzf#vim#with_preview({ "placeholder": "" }), <bang>0)',
\'command! -bar -bang Maps call fzf#vim#maps("n", <bang>0)',
\'command! -bar -bang Maps call fzf#vim#maps("*", <bang>0)',
\'command! -bar -bang Filetypes call fzf#vim#filetypes(<bang>0)',
\'command! -bang -nargs=* History call s:history(<q-args>, fzf#vim#with_preview(), <bang>0)'])

Expand Down