最近在玩fuzzyfinder插件,发现很强,但是有个问题,就是他支持的格式太多了,如果都用快捷键来调用,很难记住,后来发现可以很方便的通过插件本身实现先出命令菜单的提示,然后选择合适的命令。
通过下面的设置能够实现,F4会弹出命令提示菜单,选择合适的命令后会运行该命令,同时提示菜单里有该命令的映射,常用的可以直接使用相应的映射,不需要调用F4来提示命令。
把下面的设置放到vimrc里面:
VimL语言:
001 "
002 " FuzzyFinder 配置"{{{
003 "
004 "let g:fuf_modesDisable = [ 'mrufile', 'mrucmd', ]
005 let g:fuf_modesDisable = []
006 let g:fuf_mrufile_maxItem = 400
007 let g:fuf_mrucmd_maxItem = 400
008 nnoremap <silent> sj :FufBuffer<CR>
009 nnoremap <silent> sk :FufFileWithCurrentBufferDir<CR>
010 nnoremap <silent> sK :FufFileWithFullCwd<CR>
011 nnoremap <silent> s<C-k> :FufFile<CR>
012 nnoremap <silent> sl :FufCoverageFileChange<CR>
013 nnoremap <silent> sL :FufCoverageFileChange<CR>
014 nnoremap <silent> s<C-l> :FufCoverageFileRegister<CR>
015 nnoremap <silent> sd :FufDirWithCurrentBufferDir<CR>
016 nnoremap <silent> sD :FufDirWithFullCwd<CR>
017 nnoremap <silent> s<C-d> :FufDir<CR>
018 nnoremap <silent> sn :FufMruFile<CR>
019 nnoremap <silent> sN :FufMruFileInCwd<CR>
020 nnoremap <silent> sm :FufMruCmd<CR>
021 nnoremap <silent> su :FufBookmarkFile<CR>
022 nnoremap <silent> s<C-u> :FufBookmarkFileAdd<CR>
023 vnoremap <silent> s<C-u> :FufBookmarkFileAddAsSelectedText<CR>
024 nnoremap <silent> si :FufBookmarkDir<CR>
025 nnoremap <silent> s<C-i> :FufBookmarkDirAdd<CR>
026 nnoremap <silent> st :FufTag<CR>
027 nnoremap <silent> sT :FufTag!<CR>
028 nnoremap <silent> s<C-]> :FufTagWithCursorWord!<CR>
029 nnoremap <silent> s, :FufBufferTag<CR>
030 nnoremap <silent> s< :FufBufferTag!<CR>
031 vnoremap <silent> s, :FufBufferTagWithSelectedText!<CR>
032 vnoremap <silent> s< :FufBufferTagWithSelectedText<CR>
033 nnoremap <silent> s} :FufBufferTagWithCursorWord!<CR>
034 nnoremap <silent> s. :FufBufferTagAll<CR>
035 nnoremap <silent> s> :FufBufferTagAll!<CR>
036 vnoremap <silent> s. :FufBufferTagAllWithSelectedText!<CR>
037 vnoremap <silent> s> :FufBufferTagAllWithSelectedText<CR>
038 nnoremap <silent> s] :FufBufferTagAllWithCursorWord!<CR>
039 nnoremap <silent> sg :FufTaggedFile<CR>
040 nnoremap <silent> sG :FufTaggedFile!<CR>
041 nnoremap <silent> so :FufJumpList<CR>
042 nnoremap <silent> sp :FufChangeList<CR>
043 nnoremap <silent> sq :FufQuickfix<CR>
044 nnoremap <silent> sy :FufLine<CR>
045 nnoremap <silent> sh :FufHelp<CR>
046 nnoremap <silent> se :FufEditDataFile<CR>
047 nnoremap <silent> sr :FufRenewCache<CR>
048 "
049 " F4和shift+F4调用FuzzyFinder命令行菜单""{{{
050 "
051 function! GetAllCommands()
052 redir => commands
053 silent command
054 redir END
055 return map((split(commands, "\n")[3:]),
056 \ '":" . matchstr(v:val, ''^....\zs\S*'')')
057 endfunction
058
059 " 自定义命令行
060 let g:fuf_com_list=[':exe "FufBuffer " |" sj ',
061 \':exe "FufFileWithCurrentBufferDir " |" sk ',
062 \':exe "FufFileWithFullCwd " |" sK ',
063 \':exe "FufFile " |" s ',
064 \':exe "FufCoverageFileChange " |" sl ',
065 \':exe "FufCoverageFileChange " |" sL ',
066 \':exe "FufCoverageFileRegister " |" s ',
067 \':exe "FufDirWithCurrentBufferDir " |" sd ',
068 \':exe "FufDirWithFullCwd " |" sD ',
069 \':exe "FufDir " |" s ',
070 \':exe "FufMruFile " |" sn ',
071 \':exe "FufMruFileInCwd " |" sN ',
072 \':exe "FufMruCmd " |" sm ',
073 \':exe "FufBookmarkFile " |" su ',
074 \':exe "FufBookmarkFileAdd " |" s ',
075 \':exe "FufBookmarkFileAddAsSelectedText" |" s ',
076 \':exe "FufBookmarkDir " |" si ',
077 \':exe "FufBookmarkDirAdd " |" s ',
078 \':exe "FufTag " |" st ',
079 \':exe "FufTag! " |" sT ',
080 \':exe "FufTagWithCursorWord! " |" s ',
081 \':exe "FufBufferTag " |" s, ',
082 \':exe "FufBufferTag! " |" s< ',
083 \':exe "FufBufferTagWithSelectedText! " |" s, ',
084 \':exe "FufBufferTagWithSelectedText " |" s< ',
085 \':exe "FufBufferTagWithCursorWord! " |" s} ',
086 \':exe "FufBufferTagAll " |" s. ',
087 \':exe "FufBufferTagAll! " |" s> ',
088 \':exe "FufBufferTagAllWithSelectedText!" |" s. ',
089 \':exe "FufBufferTagAllWithSelectedText " |" s> ',
090 \':exe "FufBufferTagAllWithCursorWord! " |" s] ',
091 \':exe "FufTaggedFile " |" sg ',
092 \':exe "FufTaggedFile! " |" sG ',
093 \':exe "FufJumpList " |" so ',
094 \':exe "FufChangeList " |" sp ',
095 \':exe "FufQuickfix " |" sq ',
096 \':exe "FufLine " |" sy ',
097 \':exe "FufHelp " |" sh ',
098 \':exe "FufEditDataFile " |" se ',
099 \':exe "FufRenewCache " |" sr ',
100 \':exe "FufDir ~/" |" 更换目录从家目录jml',
101 \':exe "FufFile ~/" |" 打开文件从家目录jml',
102 \]
103
104
105 nnoremap <silent> <S-F4> :call fuf#givencmd#launch('', 0, '选择命令>', GetAllCommands())<CR>
106 nnoremap <silent> <F4> :call fuf#givencmd#launch('', 0, '选择命令>', g:fuf_com_list)<CR>
107 "}}}
阅读(4089) | 评论(0) | 转发(0) |