let g:Lf_WorkingDirectoryMode = 'Ac' let g:Lf_RootMarkers = ['.git', '.svn', '.hg', '.project', '.root'] let g:Lf_DefaultExternalTool='rg' let g:Lf_WindowPosition = 'popup'
let g:Lf_UseCache = 0 let g:Lf_PreviewInPopup = 1 let g:Lf_ShowHidden = 1"show hidden files
" preview or not let g:Lf_PreviewResult = {'Function': 0, 'BufTag': 0 }
g:Lf_WorkingDirectoryMode *g:Lf_WorkingDirectoryMode* This option customizes LeaderF's working directory. e.g., > let g:Lf_WorkingDirectoryMode = 'Ac' < c - the directory of the current working directory.(default) a - the nearest ancestor of current working directory that contains one of directories or files defined in |g:Lf_RootMarkers|. Fall back to'c' if no such ancestor directory found. A - the nearest ancestor of current file that contains one of directories or files defined in |g:Lf_RootMarkers|. Fall back to'c' if no such ancestor directory found. f - the directory of the current file. F - if the current working directory isnot the direct ancestor of current file, use the directory of the current file as LeaderF's working directory, otherwise, same as 'c'. Note: if"f", "F"is included with"a"or"A", use the behavior of"f"or "F"(as a fallback) when a root can't be found.
{file,tag,function,mru,searchHistory,cmdHistory,help,line,colorscheme,gtags, self,bufTag,buffer,rg,filetype,command,window,quickfix,loclist,jumps} filesearchfiles tag navigate tags using the tagsfile functionnavigate functions or methods in the buffer mru search most recently used files searchHistory execute the searchcommand in the history cmdHistory execute the command in the history help navigate the helptags linesearchaline in the buffer colorscheme switch between colorschemes gtags navigate tags using the gtags self execute the commands of itself bufTag navigate tags in the buffer buffersearchbuffers rg grep using rg filetype navigate the filetype commandexecute built-in/user-defined Ex commands. window search windows. quickfix navigate the quickfix. loclist navigate the location list.
好了,我可以放弃 fzf.vim, ctrp.vim, tagbar, unite.vim, denite.vim 等一系列 vim 插件了。 在日常使用中,每次都输入那么长的命令不太方便,我们可以配置以下容易记忆的快捷键。
Once LeaderF is launched: *prompt* *leaderf-prompt* <C-C>, <ESC> : quit from LeaderF. <C-R> : switch between fuzzy searchmodeand regex mode. <C-F> : switch between full path searchmodeand name onlysearchmode. <Tab> : switch tonormalmode. <C-V>, <S-Insert> : paste from clipboard. <C-U> : clear the prompt. <C-W> : delete the word before the cursor in the prompt. <C-J>, <C-K> : navigate the result list. <Up>, <Down> : recall last/nextinput pattern from history. <2-LeftMouse>or<CR> : open the file under cursoror selected(when multiple files are selected). <C-X> : open in horizontal split window. <C-]> : open in verticalsplit window. <C-T> : open in new tabpage. <F5> : refresh the cache. <C-LeftMouse>or<C-S> : select multiple files. <S-LeftMouse> : select consecutive multiple files. <C-A> : select allfiles. <C-L> : clear all selections. <BS> : delete the preceding character in the prompt. <Del> : delete the current character in the prompt. <Home>: move the cursorto the begin of the prompt. <End> : move the cursorto the end of the prompt. <Left>: move the cursor one character to the left. <Right> : move the cursor one character to the right. <C-P> : preview the result. <C-Up> : scroll up in the popup preview window. <C-Down> : scroll down in the popup preview window.
tab : 切换输入模式和 normal 模式,进入 normal 模式后可以使用 j 和 k 上下移动光标来查看文件。
q : normal 模式中,退出 LeaderF
在输入模式下,可以使用下面的快捷键进行分屏显示。
ctrl + x : 横向分割
ctrl + ] : 竖向分割
ctrl + T : tab 分割
☆ LeaderF + gtags 的配置
gtags 和 LeaderF 配置起来使用,实在是很不错。首先要配置好 gtags,关于 global 的安装详见 GNU Global 的使用,这里就不再详细说了,gtags 的配置添加下面两行即可。
1 2
let $GTAGSLABEL='native-pygments' let $GTAGSCONF='/usr/local/share/gtags/gtags.conf'
配置好系统 gtags,global ,gtags.conf 的正确路径。
1 2 3 4
let g:Lf_Global = '/usr/local/bin/global' let g:Lf_Gtags = '/usr/local/bin/gtags' let g:Lf_Gtagsconf = '/usr/local/share/gtags/gtags.conf' let g:Lf_Gtagslabel = 'native-pygments'
g:Lf_CacheDirectory *g:Lf_CacheDirectory* Set this optionto change the location of the cache directory. e.g. > let g:Lf_CacheDirectory = '/root' < On Windows, default value is'%APPDATA%'. On Linux, default value is'$XDG_CACHE_HOME' if $XDG_CACHE_HOME is defined, otherwise, default value is'$HOME/.cache'.
LeaderF gtags 最常用的 :Leaderf[!] gtags -d/-r/-s/-g, 具体的作用如下所示,! 表示直接进入 normal 模式。
1 2 3 4 5 6 7 8 9
--gtagslibpath <PATH> [<PATH> ...] Specify the paths tosearchfor library functions. -d <PATTERN>, --definition <PATTERN> Show locations of definitions. -r <PATTERN>, --reference <PATTERN> Show reference toa symbol which has definitions. -s <PATTERN>, --symbol <PATTERN> Show reference toa symbol which hasno definition. -g <PATTERN>, --grep<PATTERN>