liuchengxu / vim-which-key Goto Github PK
View Code? Open in Web Editor NEW:tulip: Vim plugin that shows keybindings in popup
Home Page: https://liuchengxu.github.io/vim-which-key/
License: MIT License
:tulip: Vim plugin that shows keybindings in popup
Home Page: https://liuchengxu.github.io/vim-which-key/
License: MIT License
call which_key#register('', "g:which_key_map")
这个函数,在打开gvim的时候会出现如图所示的错误。但是打开后在手动运行这个函数可以。
以下是代码:
Plug 'liuchengxu/vim-which-key'
set timeoutlen=500
let g:mapleader = "<Space>"
let g:maplocalleader = ','
" nnoremap :WhichKey ''
" nnoremap :WhichKey ','
let g:which_key_map = {}
" name
是一个特殊字段,如果 dict 里面的元素也是一个 dict,那么表明一个 group,比如 +file
, 就会高亮和显示 +file
。默认是 +prefix
.
" =======================================================
" 基于已经存在的快捷键映射,直接使用一个字符串说明介绍信息即可
" =======================================================
" You can pass a descriptive text to an existing mapping.
let g:which_key_map.f = { 'name' : '+file' }
nnoremap fs :update
let g:which_key_map.f.s = 'save-file'
nnoremap fd :e $MYVIMRC
let g:which_key_map.f.d = 'open-vimrc'
nnoremap oq :copen
nnoremap ol :lopen
let g:which_key_map.o = {
\ 'name' : '+open',
\ 'q' : 'open-quickfix' ,
\ 'l' : 'open-locationlist',
\ }
" =======================================================
" 不存在相关的快捷键映射,需要用一个 list:
" 第一个元素表明执行的操作,第二个是该操作的介绍
" =======================================================
" Provide commands(ex-command, // mapping, etc.) and descriptions for existing mappings
let g:which_key_map.b = {
\ 'name' : '+buffer' ,
\ '1' : ['b1' , 'buffer 1'] ,
\ '2' : ['b2' , 'buffer 2'] ,
\ 'd' : ['bd' , 'delete-buffer'] ,
\ 'f' : ['bfirst' , 'first-buffer'] ,
\ 'h' : ['Startify' , 'home-buffer'] ,
\ 'l' : ['blast' , 'last-buffer'] ,
\ 'n' : ['bnext' , 'next-buffer'] ,
\ 'p' : ['bprevious' , 'previous-buffer'] ,
\ }
call which_key#register('', "g:which_key_map")
nnoremap :WhichKey ''
vnoremap :WhichKeyVisual ''
OS: linux
Vim: NVIM v0.4.2
If you think it's a bug, please provide a minimal vimrc to reproduce:
let g:mapleader = "\<Space>"
nnoremap <silent> <Leader> :WhichKey '<Space>'<CR>
nnoremap <silent> <Space><Up> <C-w><Up>
Using above vimrc and press space (wait 1s), and then press <up>
key
Or even just press <C-w><Up>
when the popup menu showing
PS:
I can even use visual mode in this tab(if let g:which_key_use_floating_win = 0)
OS: Ubuntu 18.04
Vim: Neovim 0.3.1
If you think it's a bug, please provide a minimal vimrc to reproduce:
call plug#begin('~/.config/nvim/plugged')
Plug 'liuchengxu/vim-which-key', { 'on': ['WhichKey', 'WhichKey!'] }
call plug#end()
let mapleader = ' '
let maplocalleader = '\'
augroup vimrc
autocmd!
autocmd! User vim-which-key call which_key#register('<Space>', 'g:which_key_map')
autocmd! FileType which_key
autocmd FileType which_key set laststatus=0
\| autocmd BufLeave <buffer> set laststatus=2
augroup END
" ----------------------------------------------------------------------------
" vim-which-key
" ----------------------------------------------------------------------------
nnoremap <silent> <leader> :<c-u>WhichKey '<Space>'<CR>
vnoremap <silent> <leader> :<c-u>WhichKeyVisual '<Space>'<CR>
nnoremap <silent> <localleader> :<c-u>WhichKey '\'<CR>
let g:which_key_map = {}
let g:which_key_map.2 = 'which_key_ignore'
let g:which_key_map.3 = 'which_key_ignore'
let g:which_key_map.4 = 'which_key_ignore'
let g:which_key_map.5 = 'which_key_ignore'
let g:which_key_map.6 = 'which_key_ignore'
let g:which_key_map.7 = 'which_key_ignore'
let g:which_key_map.8 = 'which_key_ignore'
let g:which_key_map.9 = 'which_key_ignore'
let g:which_key_map.b = {
\ 'name' : '+buffer' ,
\ '1' : ['b1' , 'buffer 1'] ,
\ '2' : ['b2' , 'buffer 2'] ,
\ 'd' : ['bd' , 'delete-buffer'] ,
\ 'f' : ['bfirst' , 'first-buffer'] ,
\ 'h' : ['Startify' , 'home-buffer'] ,
\ 'l' : ['blast' , 'last-buffer'] ,
\ 'n' : ['bnext' , 'next-buffer'] ,
\ 'p' : ['bprevious' , 'previous-buffer'] ,
\ '?' : ['Buffers' , 'fzf-buffer'] ,
\ }
If I press <Space>
to active which-key, then resize neovim pane size in tmux, the neovim pane become blank until I press <ESC>
to quit which-key or complete some mapping in which-key table.
I like what vim-leader-guide does. There are some scenarios where the current behavior might be annoying:
'<leader>g'
), I don't know how to go directly back (to '<leader>'
).So the point is change how <backspace>
key works. Actually now hitting <backspace>
will change the focus to popup window somehow which does nothing good.
OS: ubuntu16.04
Vim: 8.1
let g:which_key_map = {
\ 'name' : '+Leader',
\ 'w' : '保存文件',
\ 'x' : '保存并退出文件',
\ 'q' : '退出文件',
\ 'a' : '退出所有文件',
\ 's' : '全文范围内替换光标处的单词',
\ 'f' : {
\ 'name' : '+LeaderF',
\ 'i' : '搜索当前目录下的文件',
\ 'm' : '搜索最近使用过的文件',
\ 'c' : '搜索历史命令',
\ 'f' : '搜索当前文件中定义的函数',
\ 'w' : '搜索光标处的单词',
\ 'r' : '重新打开上一次的搜索结果',
\ },
\ }
call which_key#register('<leader>', "g:which_key_map")
nnoremap <silent> <leader> :<c-u>WhichKey '<leader>'<CR>
我是按照README配置的,不知道为什么不能显示自定义的中文提示。
let g:which_key_map['w'] = {
\ 'name' : '+windows' ,
\ 'w' : ['<C-W>w' , 'other-window'] ,
\ 'd' : ['<C-W>c' , 'delete-window'] ,
\ '-' : ['<C-W>s' , 'split-window-below'] ,
\ '|' : ['<C-W>v' , 'split-window-right'] ,
\ '2' : ['<C-W>v' , 'layout-double-columns'] ,
\ 'h' : ['<C-W>h' , 'window-left'] ,
\ 'j' : ['<C-W>j' , 'window-below'] ,
\ 'l' : ['<C-W>l' , 'window-right'] ,
\ 'k' : ['<C-W>k' , 'window-up'] ,
\ 'H' : ['<C-W>5<' , 'expand-window-left'] ,
\ 'J' : ['resize +5' , 'expand-window-below'] ,
\ 'L' : ['<C-W>5>' , 'expand-window-right'] ,
\ 'K' : ['resize -5' , 'expand-window-up'] ,
\ '=' : ['<C-W>=' , 'balance-window'] ,
\ 's' : ['<C-W>s' , 'split-window-below'] ,
\ 'v' : ['<C-W>v' , 'split-window-below'] ,
\ '?' : ['Windows' , 'fzf-window'] ,
\ }
如上,dict的value,list变量的第一个元素,是指定快捷键的实现,这样就给配置带来了极大不方便。
如果能做到下面这种,自然是非常好:
let g:which_key_map['w'] = {
\ 'name' : '+windows' ,
\ 'w' : 'other-window' ,
\ 'd' : 'delete-window' ,
\ '-' : 'split-window-below' ,
\ '|' : 'split-window-right' ,
\ '2' : 'layout-double-columns' ,
\ 'h' : 'window-left' ,
\ 'j' : 'window-below' ,
\ 'l' : 'window-right' ,
\ 'k' : 'window-up' ,
\ 'H' : 'expand-window-left' ,
\ 'J' : 'expand-window-below' ,
\ 'L' : 'expand-window-right' ,
\ 'K' : 'expand-window-up' ,
\ '=' : 'balance-window' ,
\ 's' : 'split-window-below' ,
\ 'v' : 'split-window-below' ,
\ '?' : 'fzf-window' ,
\ }
理由是,有的快捷键,后面是一大串
OS: unix
Vim: nvim-3.2
If you think it's a bug, please provide a minimal vimrc to reproduce:
Plug 'liuchengxu/vim-which-key'
nnoremap <silent> <leader> :WhichKey '<Space>'<CR>
nnoremap <silent> <localleader> :WhichKey 'g'<CR>
I map <localleader>
to g
. But I cannot press gg
because I get g g is undefined
.
Please allow to run native mappings.
One of the best plugins I've seen in a long time. Thanks!
OS: Ubuntu 18.04
Vim:
VIM - Vi IMproved 8.1 (2018 May 18, compiled Aug 22 2018 11:42:48)
Included patches: 1-369
Modified by [email protected]
Compiled by [email protected]
Huge version with GTK3 GUI. Features included (+) or not (-):
+acl +extra_search +mouse_netterm +tag_old_static
+arabic +farsi +mouse_sgr -tag_any_white
+autocmd +file_in_path -mouse_sysmouse +tcl
+autochdir +find_in_path +mouse_urxvt +termguicolors
-autoservername +float +mouse_xterm +terminal
+balloon_eval +folding +multi_byte +terminfo
+balloon_eval_term -footer +multi_lang +termresponse
+browse +fork() -mzscheme +textobjects
++builtin_terms +gettext +netbeans_intg +timers
+byte_offset -hangul_input +num64 +title
+channel +iconv +packages +toolbar
+cindent +insert_expand +path_extra +user_commands
+clientserver +job +perl +vartabs
+clipboard +jumplist +persistent_undo +vertsplit
+cmdline_compl +keymap +postscript +virtualedit
+cmdline_hist +lambda +printer +visual
+cmdline_info +langmap +profile +visualextra
+comments +libcall -python +viminfo
+conceal +linebreak +python3 +vreplace
+cryptv +lispindent +quickfix +wildignore
+cscope +listcmds +reltime +wildmenu
+cursorbind +localmap +rightleft +windows
+cursorshape +lua +ruby +writebackup
+dialog_con_gui +menu +scrollbind +X11
+diff +mksession +signs -xfontset
+digraphs +modify_fname +smartindent +xim
+dnd +mouse +startuptime +xpm
-ebcdic +mouseshape +statusline +xsmp_interact
+emacs_tags +mouse_dec -sun_workshop +xterm_clipboard
+eval +mouse_gpm +syntax -xterm_save
+ex_extra -mouse_jsbterm +tag_binary
system vimrc file: "$VIM/vimrc"
user vimrc file: "$HOME/.vimrc"
2nd user vimrc file: "~/.vim/vimrc"
user exrc file: "$HOME/.exrc"
system gvimrc file: "$VIM/gvimrc"
user gvimrc file: "$HOME/.gvimrc"
2nd user gvimrc file: "~/.vim/gvimrc"
defaults file: "$VIMRUNTIME/defaults.vim"
system menu file: "$VIMRUNTIME/menu.vim"
fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK -pthread -I/usr/include/gtk-3.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -I/usr/include/gtk-3.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng16 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -Wdate-time -g -O2 -fdebug-prefix-map=/build/vim-u2a9M3/vim-8.1.0369=. -fstack-protector-strong -Wformat -Werror=format-security -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc -L. -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -fstack-protector -rdynamic -Wl,-export-dynamic -Wl,-E -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -o vim -lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0 -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lSM -lICE -lXpm -lXt -lX11 -lXdmcp -lSM -lICE -lm -ltinfo -lnsl -lselinux -lacl -lattr -lgpm -ldl -L/usr/lib -llua5.2 -Wl,-E -fstack-protector-strong -L/usr/local/lib -L/usr/lib/x86_64-linux-gnu/perl/5.26/CORE -lperl -ldl -lm -lpthread -lcrypt -L/usr/lib/python3.6/config-3.6m-x86_64-linux-gnu -lpython3.6m -lpthread -ldl -lutil -lm -L/usr/lib/x86_64-linux-gnu -ltcl8.6 -ldl -lz -lpthread -lm -lruby-2.5 -lpthread -lgmp -ldl -lcrypt -lm
Is there an option to define different mappings for same combination depending on whether it's visual or normal mode?
For example Zeavim defines its mappings like this: https://github.com/KabbAmine/zeavim.vim#mapping-. But in my case I disable them and compose which_key_map
myself. So I need to replicate similar behavior within which-key configuration.
OS: openSUSE Tumbleweed
Vim: 8.1
If you think it's a bug, please provide a minimal vimrc to reproduce:
I'm following the README.md file+#53 to add description text for maps
using the following lines(I'm using space-vim, so some of them are not actually needed):
function! UserConfig()
let g:which_key_map = {}
autocmd VimEnter * call which_key#register('<Space>', "g:which_key_map")
nnoremap <silent> <leader> :<c-u>WhichKey '<Space>'<CR>
vnoremap <silent> <leader> :<c-u>WhichKeyVisual '<Space>'<CR>
" ...
endfunction
But the following error message is displayed when I open vim:
Error detected while processing VimEnter Autocommands for "*":
E117: Unknown function: which_key#register
Press ENTER or type command to continue
When I add
nnoremap <Leader>ff :Files<CR>
let g:which_key_map.f.f = 'Files in current dir'
to add description for a map, the following error message is displayed:
Error detected while processing function spacevim#bootstrap[2]..spacevim#end[9]..UserConfig:
line 71:
E716: Key not present in Dictionary: f.f = 'Files in current dir'
Press ENTER or type command to continue
So what should I exactly do to add description for a map?
It seems that once you enter the WhichKey menu it will immediately exit upon hitting the first valid mapping, regardless of if there are additional mappings that are supersets(right term?) of that mapping.
The example that I've run into comes from commentary, which defines 'gc' and 'gcc'. If I run :WhichKey ''
its impossible to enter the second binding. As long as I don't open the whichkey menu and I do enter the correct keyset inside of timeoutlen's duration it works fine. But its impossible to reach some keymappings that would otherwise be reachable when calling them through which-key.
I noticed this because I tried setting timeoutlen to 0 and it completely broke some useful mappings.
I think it would be useful to have something like an additional whichkey specific timeout value that would allow it to keep waiting for more keys to satisfy a longer binding even if a shorter binding has already been satisfied.
OS: debian9, ubuntu18.04, macOS 10.13.6
Vim: neovim0.3.1+ (vim , gvim works mainly well)
If you think it's a bug, please provide a minimal vimrc to reproduce:
My config is here leoatchina-vim
I alias alt
to meta
as an import key like ctrl
according to skywind3000
's Vim 中正确使用 Alt映射, but only alias it when use vim
, notice that not set alt
as esc+
for nvim since it is built in
function! Alt_meta_map()
set ttimeout
if $TMUX != ''
set ttimeoutlen=20
elseif &ttimeoutlen > 60 || &ttimeoutlen <= 0
set ttimeoutlen=60
endif
map ÏP <F1>
map ÏQ <F2>
map ÏR <F3>
map ÏS <F4>
inoremap ÏP <Nop>
inoremap ÏQ <Nop>
inoremap ÏR <Nop>
inoremap ÏS <Nop>
inoremap <F5> <Nop>
inoremap <F6> <Nop>
inoremap <F7> <Nop>
inoremap <F8> <Nop>
inoremap <F9> <Nop>
inoremap <F10> <Nop>
inoremap <F11> <Nop>
inoremap <F12> <Nop>
function! s:metacode(key) # import here
if has('gui_macvim')
exec "map <D-".a:key."> <M-".a:key.">"
exec "imap <D-".a:key."> <Nop>"
elseif !(has('nvim') || has('gui_running') && !OSX()) # not for nvim
exec "set <M-".a:key.">=\e".a:key
exec "imap <M-".a:key."> <Nop>"
else
exec "imap <M-".a:key."> <Nop>"
endif
endfunction
for i in range(26)
call s:metacode(nr2char(char2nr('a') + i))
call s:metacode(nr2char(char2nr('A') + i))
endfor
let s:list = [',', '.', ';', ':', '/', '?', '{', '}', '-', '_']
for c in s:list
call s:metacode(c)
endfor
if has('gui_macvim')
nnoremap <D-1> :tabn1<CR>
nnoremap <D-2> :tabn2<CR>
nnoremap <D-3> :tabn3<CR>
nnoremap <D-4> :tabn4<CR>
nnoremap <D-5> :tabn5<CR>
nnoremap <D-6> :tabn6<CR>
nnoremap <D-7> :tabn7<CR>
nnoremap <D-8> :tabn8<CR>
nnoremap <D-9> :tabn9<CR>
nnoremap <D-0> :tablast<CR>
else
for i in range(10)
call s:metacode(nr2char(char2nr('0') + i))
endfor
nnoremap <M-1> :tabn1<CR>
nnoremap <M-2> :tabn2<CR>
nnoremap <M-3> :tabn3<CR>
nnoremap <M-4> :tabn4<CR>
nnoremap <M-5> :tabn5<CR>
nnoremap <M-6> :tabn6<CR>
nnoremap <M-7> :tabn7<CR>
nnoremap <M-8> :tabn8<CR>
nnoremap <M-9> :tabn9<CR>
nnoremap <M-0> :tablast<CR>
nnoremap <M-c> "*y
xnoremap <M-c> "*y
nnoremap <M-x> "*x
xnoremap <M-x> "*x
nnoremap <M-v> "*gP
xnoremap <M-v> "*gP
inoremap <M-v> <C-r>*
cnoremap <M-v> <C-r>*
endif
inoremap <M-w> <ESC>
inoremap <M-q> <ESC>
cnoremap <M-w> <ESC>
cnoremap <M-q> <ESC>
endfunction
call Alt_meta_map()
M-s
raise errors
nnoremap <M-s>n :set invrelativenumber<CR>
" togglePaste
nnoremap <M-s>p :set nopaste! nopaste?<CR>
" toggleFold
nnoremap <M-s>f :set nofoldenable! nofoldenable?<CR>
" toggleWrap
nnoremap <M-s>w :set nowrap! nowrap?<CR>
" toggleTrueclore
nnoremap <M-s>t :set notermguicolors! notermguicolors?<CR>
" toggle highlight
nnoremap <M-s>h :set nohlsearch! nohlsearch?<CR>
" indent_guides
if HasDirectory("vim-indent-guides")
let g:indent_guides_enable_on_vim_startup = 0
nnoremap <M-s>i :IndentGuidesToggle<Cr>
endif
" which-key
if HasDirectory("vim-which-key")
set timeoutlen=300
nnoremap <silent> <M-s> :<c-u>WhichKey '<M-s>'<CR>
endif
M-o
, for lsp , errors
nmap <M-N> :call LanguageClient#textDocument_hover()<CR>
nmap <M-o>d :call LanguageClient#textDocument_definition()<CR>
nmap <M-o>= :sp<CR>:call LanguageClient#textDocument_definition()<CR>
nmap <M-o>\ :vs<CR>:call LanguageClient#textDocument_definition()<CR>
nmap <M-o>t :call LanguageClient#textDocument_typeDefinition()<CR>
nmap <M-o>r :call LanguageClient#textDocument_references()<CR>
nmap <M-o>l :call LanguageClient#contextMenu()<CR>
nmap <M-o>n :call LanguageClient#textDocument_rename()<CR>
nmap <M-o>i :call LanguageClient#textDocument_implementation()<CR>
nmap <M-o>s :call LanguageClient#textDocument_documentSymbol(()<CR>
M-g
works for vim, seems good for nvim, but actually it is the same as g
" fugitive
if HasDirectory("vim-fugitive")
nnoremap <M-G> :Gcommit -a -v<CR>
nnoremap <M-g><Cr> :Git<Space>
if HasDirectory('gv.vim')
nnoremap <M-g>' :GV<CR>
endif
endif
if HasDirectory('vim-signify')
nnoremap <M-g>\ :SignifyDiff<Cr>
nnoremap <M-g>/ :Signify
endif
<C-p>
for leaderf/fzf, neigher vim8 nor nvim not work
It seems cannot hook ctrl
+ other key ?
if HasDirectory("LeaderF")
let g:Lf_ShortcutF = '<C-p><C-p>'
let g:Lf_ShortcutB = '<C-p>b'
let g:Lf_ReverseOrder = 0
let g:Lf_PythonVersion = g:python_version
let g:Lf_CacheDirectory = expand("~/.cache/leaderf")
let g:Lf_DefaultMode = 'Fuzzy'
if !isdirectory(g:Lf_CacheDirectory)
silent! call mkdir(g:Lf_CacheDirectory, 'p')
endif
let g:Lf_WildIgnore = {
\ 'dir': ['.svn','.git','.hg'],
\ 'file': ['*.sw?','~$*','*.bak','*.exe','*.o','*.so','*.py[co]']
\}
nnoremap T :Leaderf bufTag<cr>
nnoremap <C-p>l :Leaderf line<cr>
nnoremap <C-p>f :Leaderf function<cr>
nnoremap <C-p>m :Leaderf marks<cr>
nnoremap <C-p>c :Leaderf colorscheme --reverse<Cr>
nnoremap <C-p>h :Leaderf cmdHistory --reverse<Cr>
nnoremap <C-p>H :Leaderf history --reverse<Cr>
nnoremap <C-p>p :Leaderf
nnoremap <C-p>F :LeaderfF
nnoremap <C-p>M :LeaderfM
nnoremap <C-p>B :LeaderfB
nnoremap <C-p>F :set syntax=
nnoremap <C-p> :<c-u>WhichKey '<C-p>'<CR>
elseif HasDirectory("fzf.vim")
nnoremap <C-p><C-p> :Files<CR>
nnoremap T :BTags<CR>
nnoremap <C-p>l :Lines<CR>
nnoremap <C-p>b :Buffers<CR>
nnoremap <C-p>m :Marks<CR>
nnoremap <C-p>g :GFiles?<CR>
nnoremap <C-p>h :History/<CR>
nnoremap <C-p>c :Colors<CR>
nnoremap <C-p>t :Tags<CR>
nnoremap <C-p>A :Ag<CR>
nnoremap <C-p>R :Rg<CR>
nnoremap <C-p>F :Filetypes<CR>
nnoremap <C-p>M :Maps<CR>
nnoremap <C-p>H :History
" Mapping selecting mkppings
nmap <C-p><tab> <plug>(fzf-maps-n)
xmap <C-p><tab> <plug>(fzf-maps-x)
omap <C-p><tab> <plug>(fzf-maps-o)
imap <C-p><C-w> <plug>(fzf-complete-word)
imap <C-p><C-p> <plug>(fzf-complete-path)
imap <C-p><C-f> <plug>(fzf-complete-file-ag)
imap <C-p><C-l> <plug>(fzf-complete-line)
nnoremap <C-p> :<c-u>WhichKey '<C-p>'<CR>
endif
It is errors when use m-s
, m-o
is quite the same, just s -> o in the last line
Error detected while processing function which_key#start[16]..which_key#map#parse:
line 8:
E716: Key not present in Dictionary: lhs =~? '<Plug>.*' || mapd.lhs =~? '<SNR>.*'
E15: Invalid expression: mapd.lhs =~? '<Plug>.*' || mapd.lhs =~? '<SNR>.*'
line 12:
E716: Key not present in Dictionary: rhs])
E116: Invalid arguments for function call
E15: Invalid expression: call(g:WhichKeyFormatFunc, [mapd.rhs])
line 14:
E716: Key not present in Dictionary: lhs, key, '', '')
E116: Invalid arguments for function substitute
E15: Invalid expression: substitute(mapd.lhs, key, '', '')
line 16:
E716: Key not present in Dictionary: lhs ==? '<Space>'
E15: Invalid expression: mapd.lhs ==? '<Space>'
line 20:
E716: Key not present in Dictionary: lhs, "<Space>", " ", "g")
E116: Invalid arguments for function substitute
E15: Invalid expression: substitute(mapd.lhs, "<Space>", " ", "g")
line 21:
E716: Key not present in Dictionary: lhs, "<Tab>", "<C-I>", "g")
E116: Invalid arguments for function substitute
E15: Invalid expression: substitute(mapd.lhs, "<Tab>", "<C-I>", "g")
line 23:
E716: Key not present in Dictionary: rhs, "<SID>", "<SNR>".mapd['sid']."_", "g")
E116: Invalid arguments for function substitute
E15: Invalid expression: substitute(mapd.rhs, "<SID>", "<SNR>".mapd['sid']."_", "g")
line 25:
E716: Key not present in Dictionary: lhs != '' && mapd.display !~# 'WhichKey.*'
E15: Invalid expression: mapd.lhs != '' && mapd.display !~# 'WhichKey.*'
s : is undefined
I noticed that if you define a mapping only through the dictionary, rather than having dual definitions for it, entering the mapping, even if you do it within timeoutlen, will cause the menu to flash open for a split second then close, and then run the command. This super quick flash of the menu is rather disruptive / annoying.
I tried working around this by setting timeoutlen to 0 and just always relying on the expectation that which_key would open immediately, and that felt good except for the fact that it caused #3
Solving #2 would let me fix this issue well enough for my satisfaction in that I would make sure all my mappings are defined outside of the key map, and my key map dictionary entries would only contain information about names and aliases, not any actual command definitions.
Hey, I'm exited to see that leader-guide ideas live on with your project, nice work.
I'm curious whether vim-which-key solves issue I have with vim-leader-guide. See hecal3/vim-leader-guide#29 (comment)
Short version, I'm using default leader \
and easymotion, that by default uses <leader><leader>
as prefix for commands (like <leader><leader>f
) and I find it quite handy. leader-guide has issues when trying to add definition to these bindings. Is vim-which-key able to handle this case?
Hello, I'm using your great plugin with Vim 8.1. I've installed the plugin as a Git submodule into Vim's pack/plugins/start
directory, so it gets loaded when Vim starts.
The plugin is working fine, but when I try to create a dictionary in my .vimrc, then I get the following error message:
E117: Unknown function: which_key#register
My configuration is very simple:
let mapleader=","
let g:which_key_map = {}
call which_key#register(',', "g:which_key_map")
nnoremap <silent> <leader> :<c-u>WhichKey ','<CR>
vnoremap <silent> <leader> :<c-u>WhichKey ','<CR>
set timeoutlen=500
It seems like that at the time .vimrc
is executed, the plugin is not yet loaded? Any hints?
Error detected while processing function which_key#start[46]..which_key#window#open[3]..which_key#win
dow#fill[6]..which_key#util#create_rows:
line 54:
E684: list index out of range: 30
E116: Invalid arguments for function len
E15: Invalid expression: i < len(rows[j])
x86_64-apple-darwin17.7.0
VIM - Vi IMproved 8.1 (2018 May 18, compiled Nov 29 2018 04:52:18)
lusty-explorer provides a number of leader mappings, but only one of them shows up in which-key (<leader
> lb). Any idea why?
I have toop
set up in my config to do various tasks.
For example:
call toop#mapFunction('ToCamelCase', 'tc')
Unfortunately, if I'm too slow in hitting <leader>tciW
for example, which key's menu coming up will interrupt toop
.
Is there any way to solve this?
OS: Linux
Vim: 8.1
let g:which_key_map.a = {
\ 'name' : '+apps' ,
~ \ 't' : ['botright terminal' , 'terminal']
\ }
When i use series command like: botright terminal
, it doesn't invoke the command but instead append the command text to my current buffer
Is it possible to hide some mappings? For example do I use some mappings to jump to a buffer or window by their number. Thereby the which-key window shows each single mapping from 1 to 9 in these cases. I would like to summerize them. The former part already works, as you stated in the README that the entries of the mapping must not actually exist.
The floating window of neovim has been supported in #39. Now it's time to support vim's popup window. The advantage of floating or popup window is to get your current window layout untouched.
OS: mac
Vim: vim8
If you think it's a bug, please provide a minimal vimrc to reproduce:
let g:which_key_map.e = {
\'name': 'Edit',
\'f': {
\'name': 'File',
\'c': ['let @+=expand("%:f")', 'Copy File Name With Path'],
\}
\}
when call <leader>efc,it show:
Vim(call):E107: Missing parentheses: let @+=expand("%:f")
OS: macos
Vim: 0.4.0 dev
If you think it's a bug, please provide a minimal vimrc to reproduce:
i found the floatwindow highlight of whichkey is pmenu. so i cant use this to change highlight
highlight NormalFloat cterm=NONE ctermfg=14 ctermbg=0 gui=NONE guifg=#93a1a1 guibg=#002931
please check here
if exists('&winhighlight')
setlocal winhighlight=Normal:Pmenu
endif
This is not an issue about bugs, just share my config
OS: LINUX (manjaro, ubuntu 18.04), macOS
Have not tested windows
, but I guess also can work
Vim: GVim8.1, neovim0.3.5, vim8.1
I have test lots of ways to make use of <C->
and <M->
, and at last, I succeed
Just donot map <C->
and <M->
directly, use function to create them
PS: I map alt as meta in vim8 without gui according to Vim 中正确使用 Alt映射, so <M->
looks strange when use vim8.
set timeoutlen=300
nnoremap <silent> gg 1G
function! MapKey(key)
if len(a:key) == 3 && a:key[1] == "-" && (a:key[0] == "C" || a:key[0] == "M") "special map
if has('nvim')
let s:mapkey = "<" . a:key . ">"
else
if a:key[0] == "C" " ctrl
let s:mapkey = "<" . a:key . ">"
elseif a:key[0] == "M" "alt
let s:mapkey = a:key[2]
let s:mapkey = char2nr(s:mapkey) + 128
let s:mapkey = nr2char(s:mapkey)
endif
endif
else
let s:mapkey = a:key
endif
return s:mapkey
endfunction
function! MapWhichKey(key)
execute "WhichKey '". MapKey(a:key). "'"
endfunction
nnoremap <localleader> :call MapWhichKey('\')<Cr>
nnoremap <leader> :call MapWhichKey(' ')<Cr>
nnoremap g :call MapWhichKey('g')<Cr>
nnoremap m :call MapWhichKey('m')<Cr>
nnoremap z :call MapWhichKey('z')<Cr>
nnoremap [ :call MapWhichKey('[')<Cr>
nnoremap ] :call MapWhichKey(']')<Cr>
nnoremap <C-p> :call MapWhichKey('C-p')<Cr> # plz notice not `<>` in MapWhichKey
nnoremap <C-f> :call MapWhichKey('C-f')<Cr>
nnoremap <C-b> :call MapWhichKey('C-b')<Cr>
nnoremap <C-l> :call MapWhichKey('C-l')<Cr>
nnoremap <C-h> :call MapWhichKey('C-h')<Cr>
nnoremap <C-g> :call MapWhichKey('C-g')<Cr>
nnoremap <M-z> :call MapWhichKey('M-z')<Cr>
nnoremap <M-g> :call MapWhichKey('M-g')<Cr>
I would like to have which-key
to show only mappings for which I provide a description.
AFAICT it's not possible now.
call plug#begin('~/.vim/plugged')
Plug 'liuchengxu/vim-which-key'
call plug#end()
let g:mapleader = ";"
let g:maplocalleader = ","
set timeoutlen=300 " 按键响应 延时500毫秒
let g:which_key_hspace = 8
nnoremap <silent> <leader> :WhichKey ';'<CR>
nnoremap <silent> <localleader> :WhichKey ','<CR>
let g:which_key_map = {}
let g:which_key_map.y = ['', '复制']
let g:which_key_map.p = ['', '粘贴']
let g:which_key_map.x = ['', '剪切']
let g:which_key_map.bd = ['', '关闭buffer']
let g:which_key_map.ch = [')', '标尺']
if has("win32")
let g:which_key_map.mw = ['', '最大化']
let g:which_key_map.nw = ['', '窗口化']
let g:which_key_map.sw = ['', 'sw 待测试']
else
let g:which_key_map.mw = ['', '切换窗口化']
endif
let g:which_key_map.f = ['', '格式化选区']
let g:which_key_map.tt = ['', '翻译']
let g:which_key_map.dt = ['', 'vimwiki 更新日期']
let g:which_key_map.vt = ['', 'vimwiki todo选中']
call which_key#register(';', "g:which_key_map")
Minimize the vimrc file you want @liuchengxu
mirror from #61, #61 is already closed, I can only resend it
OS: osx 10.13.6
Vim: neovim 0.3.1
If you think it's a bug, please provide a minimal vimrc to reproduce:
call plug#begin('~/.vim/plugged')
Plug 'liuchengxu/vim-which-key', { 'on': ['WhichKey', 'WhichKey!'] }
nnoremap <silent> <leader> :<c-u>WhichKey '<Space>'<CR>
nnoremap <silent> <localleader> :<c-u>WhichKey ','<CR>
let g:which_key_map = {}
call which_key#register('<Space>', 'g:which_key_map')
call plug#end()
E117: Unknown function: which_key#register
加了这一句的话就报错,不加的话定义的快捷键就无效
OS: Arch Linux
Vim: Neovim 0.3.1
If you think it's a bug, please provide a minimal vimrc to reproduce:
First off, thank you for the great plugin/substantial improvement on leader-guide
!
One of the nicest parts (for me) about which-key
with evil
in Emacs is the display of available text objects when in operator-pending mode. For example, if I type d
and wait, a menu of the text objects and movements I could delete appears; if I continue to di
, the menu shows the objects I could delete inside of.
Is this possible to set up with vim-which-key
? I imagine one could try manually mapping all of the operators and text objects/movements to vim-which-key
dictionaries, but that seems very tedious and brittle. Is there a better/easier way? Thanks!
Hello,
Using neovim, with tpope commentary and which-key.
I set up timeoutlen to 10, because 500 was a bit slow, but now it broke gcc mapping from tpope commentary plugin.
I tryed to put it to 300, and now it fells like I have to press gcc in less than 0,3s to make it work.
Can you please explain what is the meaning of timeoutlen and why it has to exist ?
Coming form spacemacs its seems that both space-menu and gcc could live together without the need of a timeoulen variable.
Thanks for your work !
OS: Ubuntu 16.04
Vim: Vi IMproved 8.1-1729
set nocompatible
let mapleader="\<Space>"
call plug#begin('~/.vim/plug')
Plug 'liuchengxu/vim-which-key'
call plug#end()
nnoremap <silent> <leader> :<C-u>WhichKey '<Space>'<CR>
let g:which_key_map = {}
call which_key#register('<Space>', "g:which_key_map")
function W() abort
return ":echo 'test'\<CR>"
endfunction
nnoremap <expr> <leader>t W()
In the minimal vimrc above, a <expr>
mapping is defined (<leader>t
to echo 'test').
It works fine if you press <leader>t
without a break.
But if you press <leader>
and wait until which-key window appear, then press t
, which-key will ignore <expr>
and just execute W()
in normal mode.
OS: macOS 10.14
Vim: VIM - Vi IMproved 8.1 (2018 May 18, compiled Aug 14 2018 05:28:49)
macOS version
Included patches: 1-280
If you think it's a bug, please provide a minimal vimrc to reproduce:
Plugin 'liuchengxu/vim-which-key'
nnoremap <silent> <leader> :<c-u>WhickKey '<Space>'<CR>
nnoremap <silent> <localleader> :<c-u>WhichKey ','<CR>
When click I get the error E492: Not an editor command: WhichKey ' '
. Mapping works for localleader.
OS: Arch linux
Vim: NVIM v0.3.4
Hi. i use these mapping:
let g:which_key_map.g = {
\ 'name' : '+file' ,
\ 'c' : ['d' , 'Cut'] ,
\ 'o' : ['e $MYVIMRC' , 'Open vimrc'] ,
\ 's' : ['w' , 'Save'] ,
\ 'x' : ['GVgg' , 'Select whole file'] ,
\ }
Everything works except when i hit: leader+g+x and it says:
Vim:E492: Not an editor command: GVgg
tip: it actually select whole file in normal mode.
OS: WSL ubuntu (bash on windows)
Vim: Nvim v 0.3.7
I'd like to ask for an option to add a user defined escape key. A character of 27 (the unicode equivalent of escape) is hardcoded into use here and here. I'd like a new optional variable which if not null, is also checked alongside escape. In my case, I'd like it to be Ctrl-g
. that's the same key I use as an alias for escape in most other modes & having to use escape to exit which-key breaks my flow. I believe some users also rebind TAB
to escape so this could also be useful for them. This shouldn't be too big of a change, thoughts?
Hello, continuing from #2 , when I try it in command line vim in Windows, after I press space and a key I see the following error:
Error detected while processing BufLeave Auto commands for "<buffer=3>": E464: Ambiguous use of user-defined command: V
Using gvim works great.
OS: Mac
Vim: NeoVim 0.4
If you think it's a bug, please provide a minimal vimrc to reproduce:
A Great Plugin ! Can I map a key which is not leader key ?
Right now, I map ';' as leader and use well, can I map Space as well, it is a normal key
let g:which_key_map = {
" xxx works well with leader
}
let g:which_key_map['<Space>'] = {
" xxx not work with normal key <Space>
}
nnoremap <silent> <leader> :<c-u>WhichKey '<leader>'<CR>
nnoremap <silent> <Space> :<c-u>WhichKey '<Space>'<CR>
autocmd! User vim-which-key call which_key#register(g:mapleader, 'g:which_key_map')
when I enter 'Space', only native parse of vim, cannot get my description for
map be the usage of which_key#register ?
Can not recognize tab or number
minimal vimrc:
for allow-provide-description-only branch
set nocompatible
let &rtp=&rtp.','.$HOME.'/.vim/bundle/vim-which-key'
let g:mapleader="\<Space>"
nnoremap <silent> <leader> :<c-u>WhichKey '<Space>'<CR>
nnoremap <silent> <localleader> :<c-u>WhichKey ','<CR>
nnoremap <Leader>a<Tab> :echom "Hello, World"<cr>
nnoremap <Leader>1 :echom "THis is one"<cr>
let g:which_key_map = {}
let g:which_key_map.a = {
\ 'name':"Test",
\ '<Tab>':"Hello world"
\}
let g:which_key_map.1 = {
\ 'name':"One",
\}
call which_key#register('<Space>', "g:which_key_map")
colorscheme desert "default setting
filetype plugin indent on
syntax on
for master branch
set nocompatible
let &rtp=&rtp.','.$HOME.'/.vim/bundle/vim-which-key'
let g:mapleader="\<Space>"
nnoremap <silent> <leader> :<c-u>WhichKey '<Space>'<CR>
nnoremap <silent> <localleader> :<c-u>WhichKey ','<CR>
nnoremap <Leader>a<Tab> :echom "Hello, World"<cr>
nnoremap <Leader>1 :echom "THis is one"<cr>
let g:which_key_map = {}
let g:which_key_map.a = {
\ 'name':"Test",
\ '<Tab>':[':echom "THis is one"<cr>',"Hello world"]
\}
let g:which_key_map.1 = {
\ 'name':"One",
\}
call which_key#register('<Space>', "g:which_key_map")
colorscheme desert "default setting
filetype plugin indent on
syntax on
Hello,
After installing gitgutter with vim-plug, I was surprised that which_key_map.h was assign to 'prefix'
and this menu was filled with :
p → GitGutterPreviewHunk
u → GitGutterUndoHunk
s → GitGutterStageHunk
Where does this mapping come from and how can I edit it ?
Could use a real popup finally, neovim/neovim#6619
It would be nice if it were easy to determine what mode a binding was set for.
This example output show 3 configured bindings; 2 are set using nnoremap while 1 is set with inoremap. As we can see, it's not possible to understand at a glance which binding will only work when used in insert mode.
a -> foo
b -> bar
c -> baz
\-
OS: Win10
Vim: neovim0.3.0
If you think it's a bug, please provide a minimal vimrc to reproduce:
nnoremap <silent> <space> :WhichKey '<Space>'<CR>
set timeoutlen=500
autocmd! FileType which_key
autocmd FileType which_key set laststatus=0 noshowmode noruler
\| autocmd BufLeave <buffer> set laststatus=2 showmode ruler
let g:which_key_map.f = { 'name' : '+file' }
Don't display group names "file"
If use mouse click other region when had float windows, can't quit float window
:mksession mysession.vim
" exit vim
:source mysession.vim
Plugin is working as expected, but after sourcing last sessions this strange thing occure and I'm no longer to use keybindings.
I'm not quite sure what can be the problem? Maybe I should source it different way?
Or after sourcing call some function that will rebuild correctly plugin?
- Vim:
VIM - Vi IMproved 8.1 (2018 May 18, compiled Mar 6 2019 21:38:32)
Included patches: 1-996
vim --version
VIM - Vi IMproved 8.1 (2018 May 18, compiled Mar 6 2019 21:38:32)
Included patches: 1-996
Compiled by Arch Linux
Huge version with GTK3 GUI. Features included (+) or not (-):
+acl +extra_search +mouse_netterm +tag_old_static
+arabic -farsi +mouse_sgr -tag_any_white
+autocmd +file_in_path -mouse_sysmouse +tcl/dyn
+autochdir +find_in_path +mouse_urxvt +termguicolors
-autoservername +float +mouse_xterm +terminal
+balloon_eval +folding +multi_byte +terminfo
+balloon_eval_term -footer +multi_lang +termresponse
+browse +fork() -mzscheme +textobjects
++builtin_terms +gettext +netbeans_intg +textprop
+byte_offset -hangul_input +num64 +timers
+channel +iconv +packages +title
+cindent +insert_expand +path_extra +toolbar
+clientserver +job +perl/dyn +user_commands
+clipboard +jumplist +persistent_undo +vartabs
+cmdline_compl +keymap +postscript +vertsplit
+cmdline_hist +lambda +printer +virtualedit
+cmdline_info +langmap +profile +visual
+comments +libcall +python/dyn +visualextra
+conceal +linebreak +python3/dyn +viminfo
+cryptv +lispindent +quickfix +vreplace
+cscope +listcmds +reltime +wildignore
+cursorbind +localmap +rightleft +wildmenu
+cursorshape +lua/dyn +ruby/dyn +windows
+dialog_con_gui +menu +scrollbind +writebackup
+diff +mksession +signs +X11
+digraphs +modify_fname +smartindent -xfontset
+dnd +mouse +startuptime +xim
-ebcdic +mouseshape +statusline -xpm
+emacs_tags +mouse_dec -sun_workshop +xsmp_interact
+eval +mouse_gpm +syntax +xterm_clipboard
+ex_extra -mouse_jsbterm +tag_binary -xterm_save`
OS: ubuntu16.04
Vim: 8.1
请问如何映射Ctrl键呢?我在文档里面没有看到类似的例子。
这样写是错误的。
nnoremap <silent> <ctrl> :<c-u>WhichKeyVisual '<ctrl>'<CR>
OS: Mac 10.12
Vim: 7.4.8056
Error detected while processing function which_key#register:
line 3:
E121: Undefined variable: key:val
E15: Invalid expression: key:val
E116: Invalid arguments for function extend
Press ENTER or type command to continue
vim-which-key works OK on vim 8 but should we support vim-which-key for vim 7?
call plug#begin('~/.vim/plugged')
Plug 'liuchengxu/vim-which-key'
call plug#end()
let g:mapleader = ";"
let g:maplocalleader = ","
set timeoutlen=300 " 按键响应 延时500毫秒
let g:which_key_hspace = 8
nnoremap <silent> <leader> :WhichKey ';'<CR>
nnoremap <silent> <localleader> :WhichKey ','<CR>
let g:which_key_map = {}
let g:which_key_map.y = ['', '复制']
let g:which_key_map.p = ['', '粘贴']
let g:which_key_map.x = ['', '剪切']
let g:which_key_map.bd = ['', '关闭buffer']
let g:which_key_map.ch = [')', '标尺']
if has("win32")
let g:which_key_map.mw = ['', '最大化']
let g:which_key_map.nw = ['', '窗口化']
let g:which_key_map.sw = ['', 'sw 待测试']
else
let g:which_key_map.mw = ['', '切换窗口化']
endif
let g:which_key_map.f = ['', '格式化选区']
let g:which_key_map.tt = ['', '翻译']
let g:which_key_map.dt = ['', 'vimwiki 更新日期']
let g:which_key_map.vt = ['', 'vimwiki todo选中']
call which_key#register(';', "g:which_key_map")
你要的最小化 .vimrc文件 @liuchengxu
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.