Vim基础篇(十一)——模糊搜索插件LeaderF
前言:
代码量一大,搜索就是很关键的功能,Vim安装LeaderF后可以像IDE那样模糊搜索。个人认为Vim最值得安装的强大插件是模糊搜索、代码补全、语法查错三种插件。
1 安装LeaderF
目前功能最强的模糊搜索插件之一有 Yggdroot/LeaderF ,不光支持模糊搜索函数、文件、字符串,还能模糊搜索缓存。
在.vimrc文件中添加如下配置安装LeaderF。
1
| Plug 'Yggdroot/LeaderF', {'do': ':LeaderfInstallCExtension'}
|
在Vim中运行指令 :PlugInstall
完成插件安装。如果使用Vim主要开发c/c++,建议安装 LeaderfInstallCExtension 支持,它将提供对c/c++更好的搜索支持。
安装Leaderf或执行指令 :LeaderfInstallCExtension
后可能遇到如下报错。
Vim基础篇(十一)——模糊搜索插件LeaderF
前言:
代码量一大,搜索就是很关键的功能,Vim安装LeaderF后可以像IDE那样模糊搜索。个人认为Vim最值得安装的强大插件是模糊搜索、代码补全、语法查错三种插件。
1 安装LeaderF
目前功能最强的模糊搜索插件之一有 Yggdroot/LeaderF ,不光支持模糊搜索函数、文件、字符串,还能模糊搜索缓存。
在.vimrc文件中添加如下配置安装LeaderF。
1
| Plug 'Yggdroot/LeaderF', {'do': ':LeaderfInstallCExtension'}
|
在Vim中运行指令 :PlugInstall
完成插件安装。如果使用Vim主要开发c/c++,建议安装 LeaderfInstallCExtension 支持,它将提供对c/c++更好的搜索支持。
安装Leaderf或执行指令 :LeaderfInstallCExtension
后可能遇到如下报错。

这是由于子系统Ubuntu还未安装gcc导致,在WSL Ubuntu中执行指令安装gcc。
1
| sudo apt-get install gcc
|
如果以上指令执行出错,请切换到root权限执行 apt-get 更新指令,将其升级到新版本。
再次执行 :LeaderfInstallCExtension
指令发现还有报错。

为了解决词错误,在子系统Ubuntu中执行检查已安装的python版本,建议安装python3,WSL Ubuntu默认安装好了python3,我们输入指令 python3 --version
查看安装的python3版本。比如我安装的是 python3 v3.8.5,那么需要在子系统Ubuntu中安装python-dev可以输入以下指令。
1
| sudo spt-get install python3.8-dev
|
解决上面错误后再次在Vim中输入 :LeaderfInstallCExtension
即可正确完成安装。
2 安装Ripgrep
BurntSushi/ripgrep 是一个非常强大的命令行搜索工具,Leaderf的rg搜索功能依赖于该工具,因此我们需要安装它。ripgrep工具并不是Vim的插件,我们需要为子系统Ubuntu安装它,在命令行执行指令安装。
1
| sudo apt-get install ripgrep
|
安装完成后即可正常使用 :Leaderf rg
搜索功能,该指令可以用来模糊搜索工程内的所有字符串。
gtags是比ctags功能更加强大的代码标签生成插件,通过gtags不光能找到函数定义,还能找到函数声明。
Leaderf可以自动管理gtags,安装gtags可以使Leaderf功能更加强大。在子系统Ubuntu中输入以下指令安装gtags。
1
| sudo apt-get install global
|
Ctags可以遍历源代码文件生成tags文件,对代码解析,文件内记录了变量名、函数名等,是很多搜索和显示插件工作的依赖基础。要在Leaderf中使用 :Leaderf function
搜索函数,需要安装Ctags并为代码生成tags文件。详细将在下一篇文章中讲解Ctags,即其自动化管理插件。
5 配置LeaderF
在配置文件中添加以下配置。
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" "Yggdroot/LeaderF let g:Lf_WindowPosition = 'popup' "使能浮动窗口,需要Vim 8.1.1615以上版本。 let g:Lf_PreviewInPopup = 1 "使能按ctrl p键在弹出窗口中预览结果。 let g:Lf_HideHelp = 1 "隐藏帮助信息。 let g:Lf_UseCache = 0 let g:Lf_CacheDirectory = expand('~/.VimCache/') "设置Leaderf缓存根目录。 let g:Lf_StlSeparator = { 'left': '', 'right': '' } "分隔符号。 let g:Lf_ShowDevIcons = 0 "不显示图标。
"gtags配置 let g:Lf_GtagsAutoGenerate = 1 "自动生成gtags数据库。保存在~/.vimcache/.lfcache/gtags/。 let g:Lf_RootMarkers = ['.git', '.svn'] "工程根目录标识。 let g:Lf_Gtagslabel = 'native-pygments'
|

建议设置以下快捷键。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| "搜索Buffer。 noremap <leader>fb :<C-U><C-R>=printf("Leaderf buffer %s", "")<CR><CR> "历史打开过的文件。 noremap <leader>fm :<C-U><C-R>=printf("Leaderf mru %s", "")<CR><CR> "在buftag中搜索。 noremap <leader>ft :<C-U><C-R>=printf("Leaderf bufTag %s", "")<CR><CR> "搜索行。 noremap <leader>fl :<C-U><C-R>=printf("Leaderf line %s", "")<CR><CR>
"通过Leaderf rg在当前缓存中搜索光标下的字符串,需按回车确认。 noremap <C-B> :<C-U><C-R>=printf("Leaderf! rg --current-buffer -e %s ", expand("<cword>"))<CR> "通过Leaderf rg搜索光标下的字符串,需按回车确认。 noremap <C-F> :<C-U><C-R>=printf("Leaderf! rg -e %s ", expand("<cword>"))<CR> "在当前目录中跳转到光标下文件。 xnoremap gf :<C-U><C-R>=printf("Leaderf! rg -F -e %s ", leaderf#Rg#visual())<CR> "打开最近一次Leaderf rg搜索窗口。 noremap go :<C-U>Leaderf! rg --recall<CR>
"搜索当前光标下函数引用,如果搜索结果只有一个则直接跳转。 noremap <leader>fr :<C-U><C-R>=printf("Leaderf! gtags -r %s --auto-jump", expand("<cword>"))<CR><CR> "搜索当前光标下函数定义,如果搜索结果只有一个则直接跳转。 noremap <leader>fd :<C-U><C-R>=printf("Leaderf! gtags -d %s --auto-jump", expand("<cword>"))<CR><CR> "打开最近一次gtags搜索窗口。 noremap <leader>fo :<C-U><C-R>=printf("Leaderf! gtags --recall %s", "")<CR><CR> "跳转到下一个搜索结果。 noremap <leader>fn :<C-U><C-R>=printf("Leaderf gtags --next %s", "")<CR><CR> "跳转到上一个搜索结果。 noremap <leader>fp :<C-U><C-R>=printf("Leaderf gtags --previous %s", "")<CR><CR>
|
以上是作者推荐的快捷键映射,但实际使用中用不到这么多,我进行筛选以下配置如下。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| "Yggdroot/LeaderF "按键映射前缀: <leader>f。 "文件搜索。 nnoremap <silent> <leader>ff :Leaderf file<CR> "历史打开过的文件。 nnoremap <silent> <leader>fm :Leaderf mru<CR> "Buffer。 nnoremap <silent> <leader>fb :Leaderf buffer<CR> "函数搜索(仅当前文件里)。 nnoremap <silent> <leader>fF :Leaderf function<CR> "grep模糊搜索。 nnoremap <silent> <leader>fg :Leaderf rg<CR> "搜索行。 nnoremap <silent> <leader>fl :Leaderf line<CR>
"通过Leaderf rg在当前缓存中搜索光标下的字符串。 noremap <leader>f<c-b> :<C-U><C-R>=printf("Leaderf! rg --current-buffer -e %s ", expand("<cword>"))<CR><CR> "通过Leaderf rg搜索光标下的字符串。 noremap <leader>f<c-f> :<C-U><C-R>=printf("Leaderf! rg -e %s ", expand("<cword>"))<CR><CR> "打开最近一次Leaderf rg搜索窗口。 noremap <leader>fr :<C-U>Leaderf! rg --recall<CR>
"搜索当前光标下函数引用,如果搜索结果只有一个则直接跳转。 noremap <leader>fc :<C-U><C-R>=printf("Leaderf! gtags -r %s --auto-jump", expand("<cword>"))<CR><CR> "搜索当前光标下函数定义,如果搜索结果只有一个则直接跳转。 noremap <leader>fd :<C-U><C-R>=printf("Leaderf! gtags -d %s --auto-jump", expand("<cword>"))<CR><CR> "打开上一次gtags搜索窗口。 noremap <leader>fR :<C-U><C-R>=printf("Leaderf! gtags --recall %s", "")<CR><CR> "跳转到下一个搜索结果。 noremap <leader>fn :<C-U><C-R>=printf("Leaderf gtags --next %s", "")<CR><CR> "跳转到上一个搜索结果。 noremap <leader>fp :<C-U><C-R>=printf("Leaderf gtags --previous %s", "")<CR><CR>
|
这是由于子系统Ubuntu还未安装gcc导致,在WSL Ubuntu中执行指令安装gcc。
1
| sudo apt-get install gcc
|
如果以上指令执行出错,请切换到root权限执行 apt-get 更新指令,将其升级到新版本。
再次执行 :LeaderfInstallCExtension
指令发现还有报错。
Vim基础篇(十一)——模糊搜索插件LeaderF
前言:
代码量一大,搜索就是很关键的功能,Vim安装LeaderF后可以像IDE那样模糊搜索。个人认为Vim最值得安装的强大插件是模糊搜索、代码补全、语法查错三种插件。
1 安装LeaderF
目前功能最强的模糊搜索插件之一有 Yggdroot/LeaderF ,不光支持模糊搜索函数、文件、字符串,还能模糊搜索缓存。
在.vimrc文件中添加如下配置安装LeaderF。
1
| Plug 'Yggdroot/LeaderF', {'do': ':LeaderfInstallCExtension'}
|
在Vim中运行指令 :PlugInstall
完成插件安装。如果使用Vim主要开发c/c++,建议安装 LeaderfInstallCExtension 支持,它将提供对c/c++更好的搜索支持。
安装Leaderf或执行指令 :LeaderfInstallCExtension
后可能遇到如下报错。

这是由于子系统Ubuntu还未安装gcc导致,在WSL Ubuntu中执行指令安装gcc。
1
| sudo apt-get install gcc
|
如果以上指令执行出错,请切换到root权限执行 apt-get 更新指令,将其升级到新版本。
再次执行 :LeaderfInstallCExtension
指令发现还有报错。

为了解决词错误,在子系统Ubuntu中执行检查已安装的python版本,建议安装python3,WSL Ubuntu默认安装好了python3,我们输入指令 python3 --version
查看安装的python3版本。比如我安装的是 python3 v3.8.5,那么需要在子系统Ubuntu中安装python-dev可以输入以下指令。
1
| sudo spt-get install python3.8-dev
|
解决上面错误后再次在Vim中输入 :LeaderfInstallCExtension
即可正确完成安装。
2 安装Ripgrep
BurntSushi/ripgrep 是一个非常强大的命令行搜索工具,Leaderf的rg搜索功能依赖于该工具,因此我们需要安装它。ripgrep工具并不是Vim的插件,我们需要为子系统Ubuntu安装它,在命令行执行指令安装。
1
| sudo apt-get install ripgrep
|
安装完成后即可正常使用 :Leaderf rg
搜索功能,该指令可以用来模糊搜索工程内的所有字符串。
gtags是比ctags功能更加强大的代码标签生成插件,通过gtags不光能找到函数定义,还能找到函数声明。
Leaderf可以自动管理gtags,安装gtags可以使Leaderf功能更加强大。在子系统Ubuntu中输入以下指令安装gtags。
1
| sudo apt-get install global
|
Ctags可以遍历源代码文件生成tags文件,对代码解析,文件内记录了变量名、函数名等,是很多搜索和显示插件工作的依赖基础。要在Leaderf中使用 :Leaderf function
搜索函数,需要安装Ctags并为代码生成tags文件。详细将在下一篇文章中讲解Ctags,即其自动化管理插件。
5 配置LeaderF
在配置文件中添加以下配置。
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" "Yggdroot/LeaderF let g:Lf_WindowPosition = 'popup' "使能浮动窗口,需要Vim 8.1.1615以上版本。 let g:Lf_PreviewInPopup = 1 "使能按ctrl p键在弹出窗口中预览结果。 let g:Lf_HideHelp = 1 "隐藏帮助信息。 let g:Lf_UseCache = 0 let g:Lf_CacheDirectory = expand('~/.VimCache/') "设置Leaderf缓存根目录。 let g:Lf_StlSeparator = { 'left': '', 'right': '' } "分隔符号。 let g:Lf_ShowDevIcons = 0 "不显示图标。
"gtags配置 let g:Lf_GtagsAutoGenerate = 1 "自动生成gtags数据库。保存在~/.vimcache/.lfcache/gtags/。 let g:Lf_RootMarkers = ['.git', '.svn'] "工程根目录标识。 let g:Lf_Gtagslabel = 'native-pygments'
|

建议设置以下快捷键。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| "搜索Buffer。 noremap <leader>fb :<C-U><C-R>=printf("Leaderf buffer %s", "")<CR><CR> "历史打开过的文件。 noremap <leader>fm :<C-U><C-R>=printf("Leaderf mru %s", "")<CR><CR> "在buftag中搜索。 noremap <leader>ft :<C-U><C-R>=printf("Leaderf bufTag %s", "")<CR><CR> "搜索行。 noremap <leader>fl :<C-U><C-R>=printf("Leaderf line %s", "")<CR><CR>
"通过Leaderf rg在当前缓存中搜索光标下的字符串,需按回车确认。 noremap <C-B> :<C-U><C-R>=printf("Leaderf! rg --current-buffer -e %s ", expand("<cword>"))<CR> "通过Leaderf rg搜索光标下的字符串,需按回车确认。 noremap <C-F> :<C-U><C-R>=printf("Leaderf! rg -e %s ", expand("<cword>"))<CR> "在当前目录中跳转到光标下文件。 xnoremap gf :<C-U><C-R>=printf("Leaderf! rg -F -e %s ", leaderf#Rg#visual())<CR> "打开最近一次Leaderf rg搜索窗口。 noremap go :<C-U>Leaderf! rg --recall<CR>
"搜索当前光标下函数引用,如果搜索结果只有一个则直接跳转。 noremap <leader>fr :<C-U><C-R>=printf("Leaderf! gtags -r %s --auto-jump", expand("<cword>"))<CR><CR> "搜索当前光标下函数定义,如果搜索结果只有一个则直接跳转。 noremap <leader>fd :<C-U><C-R>=printf("Leaderf! gtags -d %s --auto-jump", expand("<cword>"))<CR><CR> "打开最近一次gtags搜索窗口。 noremap <leader>fo :<C-U><C-R>=printf("Leaderf! gtags --recall %s", "")<CR><CR> "跳转到下一个搜索结果。 noremap <leader>fn :<C-U><C-R>=printf("Leaderf gtags --next %s", "")<CR><CR> "跳转到上一个搜索结果。 noremap <leader>fp :<C-U><C-R>=printf("Leaderf gtags --previous %s", "")<CR><CR>
|
以上是作者推荐的快捷键映射,但实际使用中用不到这么多,我进行筛选以下配置如下。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| "Yggdroot/LeaderF "按键映射前缀: <leader>f。 "文件搜索。 nnoremap <silent> <leader>ff :Leaderf file<CR> "历史打开过的文件。 nnoremap <silent> <leader>fm :Leaderf mru<CR> "Buffer。 nnoremap <silent> <leader>fb :Leaderf buffer<CR> "函数搜索(仅当前文件里)。 nnoremap <silent> <leader>fF :Leaderf function<CR> "grep模糊搜索。 nnoremap <silent> <leader>fg :Leaderf rg<CR> "搜索行。 nnoremap <silent> <leader>fl :Leaderf line<CR>
"通过Leaderf rg在当前缓存中搜索光标下的字符串。 noremap <leader>f<c-b> :<C-U><C-R>=printf("Leaderf! rg --current-buffer -e %s ", expand("<cword>"))<CR><CR> "通过Leaderf rg搜索光标下的字符串。 noremap <leader>f<c-f> :<C-U><C-R>=printf("Leaderf! rg -e %s ", expand("<cword>"))<CR><CR> "打开最近一次Leaderf rg搜索窗口。 noremap <leader>fr :<C-U>Leaderf! rg --recall<CR>
"搜索当前光标下函数引用,如果搜索结果只有一个则直接跳转。 noremap <leader>fc :<C-U><C-R>=printf("Leaderf! gtags -r %s --auto-jump", expand("<cword>"))<CR><CR> "搜索当前光标下函数定义,如果搜索结果只有一个则直接跳转。 noremap <leader>fd :<C-U><C-R>=printf("Leaderf! gtags -d %s --auto-jump", expand("<cword>"))<CR><CR> "打开上一次gtags搜索窗口。 noremap <leader>fR :<C-U><C-R>=printf("Leaderf! gtags --recall %s", "")<CR><CR> "跳转到下一个搜索结果。 noremap <leader>fn :<C-U><C-R>=printf("Leaderf gtags --next %s", "")<CR><CR> "跳转到上一个搜索结果。 noremap <leader>fp :<C-U><C-R>=printf("Leaderf gtags --previous %s", "")<CR><CR>
|
为了解决词错误,在子系统Ubuntu中执行检查已安装的python版本,建议安装python3,WSL Ubuntu默认安装好了python3,我们输入指令 python3 --version
查看安装的python3版本。比如我安装的是 python3 v3.8.5,那么需要在子系统Ubuntu中安装python-dev可以输入以下指令。
1
| sudo spt-get install python3.8-dev
|
解决上面错误后再次在Vim中输入 :LeaderfInstallCExtension
即可正确完成安装。
2 安装Ripgrep
BurntSushi/ripgrep 是一个非常强大的命令行搜索工具,Leaderf的rg搜索功能依赖于该工具,因此我们需要安装它。ripgrep工具并不是Vim的插件,我们需要为子系统Ubuntu安装它,在命令行执行指令安装。
1
| sudo apt-get install ripgrep
|
安装完成后即可正常使用 :Leaderf rg
搜索功能,该指令可以用来模糊搜索工程内的所有字符串。
gtags是比ctags功能更加强大的代码标签生成插件,通过gtags不光能找到函数定义,还能找到函数声明。
Leaderf可以自动管理gtags,安装gtags可以使Leaderf功能更加强大。在子系统Ubuntu中输入以下指令安装gtags。
1
| sudo apt-get install global
|
Ctags可以遍历源代码文件生成tags文件,对代码解析,文件内记录了变量名、函数名等,是很多搜索和显示插件工作的依赖基础。要在Leaderf中使用 :Leaderf function
搜索函数,需要安装Ctags并为代码生成tags文件。详细将在下一篇文章中讲解Ctags,即其自动化管理插件。
5 配置LeaderF
在配置文件中添加以下配置。
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" "Yggdroot/LeaderF let g:Lf_WindowPosition = 'popup' "使能浮动窗口,需要Vim 8.1.1615以上版本。 let g:Lf_PreviewInPopup = 1 "使能按ctrl p键在弹出窗口中预览结果。 let g:Lf_HideHelp = 1 "隐藏帮助信息。 let g:Lf_UseCache = 0 let g:Lf_CacheDirectory = expand('~/.VimCache/') "设置Leaderf缓存根目录。 let g:Lf_StlSeparator = { 'left': '', 'right': '' } "分隔符号。 let g:Lf_ShowDevIcons = 0 "不显示图标。
"gtags配置 let g:Lf_GtagsAutoGenerate = 1 "自动生成gtags数据库。保存在~/.vimcache/.lfcache/gtags/。 let g:Lf_RootMarkers = ['.git', '.svn'] "工程根目录标识。 let g:Lf_Gtagslabel = 'native-pygments'
|
Vim基础篇(十一)——模糊搜索插件LeaderF
前言:
代码量一大,搜索就是很关键的功能,Vim安装LeaderF后可以像IDE那样模糊搜索。个人认为Vim最值得安装的强大插件是模糊搜索、代码补全、语法查错三种插件。
1 安装LeaderF
目前功能最强的模糊搜索插件之一有 Yggdroot/LeaderF ,不光支持模糊搜索函数、文件、字符串,还能模糊搜索缓存。
在.vimrc文件中添加如下配置安装LeaderF。
1
| Plug 'Yggdroot/LeaderF', {'do': ':LeaderfInstallCExtension'}
|
在Vim中运行指令 :PlugInstall
完成插件安装。如果使用Vim主要开发c/c++,建议安装 LeaderfInstallCExtension 支持,它将提供对c/c++更好的搜索支持。
安装Leaderf或执行指令 :LeaderfInstallCExtension
后可能遇到如下报错。

这是由于子系统Ubuntu还未安装gcc导致,在WSL Ubuntu中执行指令安装gcc。
1
| sudo apt-get install gcc
|
如果以上指令执行出错,请切换到root权限执行 apt-get 更新指令,将其升级到新版本。
再次执行 :LeaderfInstallCExtension
指令发现还有报错。

为了解决词错误,在子系统Ubuntu中执行检查已安装的python版本,建议安装python3,WSL Ubuntu默认安装好了python3,我们输入指令 python3 --version
查看安装的python3版本。比如我安装的是 python3 v3.8.5,那么需要在子系统Ubuntu中安装python-dev可以输入以下指令。
1
| sudo spt-get install python3.8-dev
|
解决上面错误后再次在Vim中输入 :LeaderfInstallCExtension
即可正确完成安装。
2 安装Ripgrep
BurntSushi/ripgrep 是一个非常强大的命令行搜索工具,Leaderf的rg搜索功能依赖于该工具,因此我们需要安装它。ripgrep工具并不是Vim的插件,我们需要为子系统Ubuntu安装它,在命令行执行指令安装。
1
| sudo apt-get install ripgrep
|
安装完成后即可正常使用 :Leaderf rg
搜索功能,该指令可以用来模糊搜索工程内的所有字符串。
gtags是比ctags功能更加强大的代码标签生成插件,通过gtags不光能找到函数定义,还能找到函数声明。
Leaderf可以自动管理gtags,安装gtags可以使Leaderf功能更加强大。在子系统Ubuntu中输入以下指令安装gtags。
1
| sudo apt-get install global
|
Ctags可以遍历源代码文件生成tags文件,对代码解析,文件内记录了变量名、函数名等,是很多搜索和显示插件工作的依赖基础。要在Leaderf中使用 :Leaderf function
搜索函数,需要安装Ctags并为代码生成tags文件。详细将在下一篇文章中讲解Ctags,即其自动化管理插件。
5 配置LeaderF
在配置文件中添加以下配置。
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" "Yggdroot/LeaderF let g:Lf_WindowPosition = 'popup' "使能浮动窗口,需要Vim 8.1.1615以上版本。 let g:Lf_PreviewInPopup = 1 "使能按ctrl p键在弹出窗口中预览结果。 let g:Lf_HideHelp = 1 "隐藏帮助信息。 let g:Lf_UseCache = 0 let g:Lf_CacheDirectory = expand('~/.VimCache/') "设置Leaderf缓存根目录。 let g:Lf_StlSeparator = { 'left': '', 'right': '' } "分隔符号。 let g:Lf_ShowDevIcons = 0 "不显示图标。
"gtags配置 let g:Lf_GtagsAutoGenerate = 1 "自动生成gtags数据库。保存在~/.vimcache/.lfcache/gtags/。 let g:Lf_RootMarkers = ['.git', '.svn'] "工程根目录标识。 let g:Lf_Gtagslabel = 'native-pygments'
|

建议设置以下快捷键。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| "搜索Buffer。 noremap <leader>fb :<C-U><C-R>=printf("Leaderf buffer %s", "")<CR><CR> "历史打开过的文件。 noremap <leader>fm :<C-U><C-R>=printf("Leaderf mru %s", "")<CR><CR> "在buftag中搜索。 noremap <leader>ft :<C-U><C-R>=printf("Leaderf bufTag %s", "")<CR><CR> "搜索行。 noremap <leader>fl :<C-U><C-R>=printf("Leaderf line %s", "")<CR><CR>
"通过Leaderf rg在当前缓存中搜索光标下的字符串,需按回车确认。 noremap <C-B> :<C-U><C-R>=printf("Leaderf! rg --current-buffer -e %s ", expand("<cword>"))<CR> "通过Leaderf rg搜索光标下的字符串,需按回车确认。 noremap <C-F> :<C-U><C-R>=printf("Leaderf! rg -e %s ", expand("<cword>"))<CR> "在当前目录中跳转到光标下文件。 xnoremap gf :<C-U><C-R>=printf("Leaderf! rg -F -e %s ", leaderf#Rg#visual())<CR> "打开最近一次Leaderf rg搜索窗口。 noremap go :<C-U>Leaderf! rg --recall<CR>
"搜索当前光标下函数引用,如果搜索结果只有一个则直接跳转。 noremap <leader>fr :<C-U><C-R>=printf("Leaderf! gtags -r %s --auto-jump", expand("<cword>"))<CR><CR> "搜索当前光标下函数定义,如果搜索结果只有一个则直接跳转。 noremap <leader>fd :<C-U><C-R>=printf("Leaderf! gtags -d %s --auto-jump", expand("<cword>"))<CR><CR> "打开最近一次gtags搜索窗口。 noremap <leader>fo :<C-U><C-R>=printf("Leaderf! gtags --recall %s", "")<CR><CR> "跳转到下一个搜索结果。 noremap <leader>fn :<C-U><C-R>=printf("Leaderf gtags --next %s", "")<CR><CR> "跳转到上一个搜索结果。 noremap <leader>fp :<C-U><C-R>=printf("Leaderf gtags --previous %s", "")<CR><CR>
|
以上是作者推荐的快捷键映射,但实际使用中用不到这么多,我进行筛选以下配置如下。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| "Yggdroot/LeaderF "按键映射前缀: <leader>f。 "文件搜索。 nnoremap <silent> <leader>ff :Leaderf file<CR> "历史打开过的文件。 nnoremap <silent> <leader>fm :Leaderf mru<CR> "Buffer。 nnoremap <silent> <leader>fb :Leaderf buffer<CR> "函数搜索(仅当前文件里)。 nnoremap <silent> <leader>fF :Leaderf function<CR> "grep模糊搜索。 nnoremap <silent> <leader>fg :Leaderf rg<CR> "搜索行。 nnoremap <silent> <leader>fl :Leaderf line<CR>
"通过Leaderf rg在当前缓存中搜索光标下的字符串。 noremap <leader>f<c-b> :<C-U><C-R>=printf("Leaderf! rg --current-buffer -e %s ", expand("<cword>"))<CR><CR> "通过Leaderf rg搜索光标下的字符串。 noremap <leader>f<c-f> :<C-U><C-R>=printf("Leaderf! rg -e %s ", expand("<cword>"))<CR><CR> "打开最近一次Leaderf rg搜索窗口。 noremap <leader>fr :<C-U>Leaderf! rg --recall<CR>
"搜索当前光标下函数引用,如果搜索结果只有一个则直接跳转。 noremap <leader>fc :<C-U><C-R>=printf("Leaderf! gtags -r %s --auto-jump", expand("<cword>"))<CR><CR> "搜索当前光标下函数定义,如果搜索结果只有一个则直接跳转。 noremap <leader>fd :<C-U><C-R>=printf("Leaderf! gtags -d %s --auto-jump", expand("<cword>"))<CR><CR> "打开上一次gtags搜索窗口。 noremap <leader>fR :<C-U><C-R>=printf("Leaderf! gtags --recall %s", "")<CR><CR> "跳转到下一个搜索结果。 noremap <leader>fn :<C-U><C-R>=printf("Leaderf gtags --next %s", "")<CR><CR> "跳转到上一个搜索结果。 noremap <leader>fp :<C-U><C-R>=printf("Leaderf gtags --previous %s", "")<CR><CR>
|
建议设置以下快捷键。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| "搜索Buffer。 noremap <leader>fb :<C-U><C-R>=printf("Leaderf buffer %s", "")<CR><CR> "历史打开过的文件。 noremap <leader>fm :<C-U><C-R>=printf("Leaderf mru %s", "")<CR><CR> "在buftag中搜索。 noremap <leader>ft :<C-U><C-R>=printf("Leaderf bufTag %s", "")<CR><CR> "搜索行。 noremap <leader>fl :<C-U><C-R>=printf("Leaderf line %s", "")<CR><CR>
"通过Leaderf rg在当前缓存中搜索光标下的字符串,需按回车确认。 noremap <C-B> :<C-U><C-R>=printf("Leaderf! rg --current-buffer -e %s ", expand("<cword>"))<CR> "通过Leaderf rg搜索光标下的字符串,需按回车确认。 noremap <C-F> :<C-U><C-R>=printf("Leaderf! rg -e %s ", expand("<cword>"))<CR> "在当前目录中跳转到光标下文件。 xnoremap gf :<C-U><C-R>=printf("Leaderf! rg -F -e %s ", leaderf#Rg#visual())<CR> "打开最近一次Leaderf rg搜索窗口。 noremap go :<C-U>Leaderf! rg --recall<CR>
"搜索当前光标下函数引用,如果搜索结果只有一个则直接跳转。 noremap <leader>fr :<C-U><C-R>=printf("Leaderf! gtags -r %s --auto-jump", expand("<cword>"))<CR><CR> "搜索当前光标下函数定义,如果搜索结果只有一个则直接跳转。 noremap <leader>fd :<C-U><C-R>=printf("Leaderf! gtags -d %s --auto-jump", expand("<cword>"))<CR><CR> "打开最近一次gtags搜索窗口。 noremap <leader>fo :<C-U><C-R>=printf("Leaderf! gtags --recall %s", "")<CR><CR> "跳转到下一个搜索结果。 noremap <leader>fn :<C-U><C-R>=printf("Leaderf gtags --next %s", "")<CR><CR> "跳转到上一个搜索结果。 noremap <leader>fp :<C-U><C-R>=printf("Leaderf gtags --previous %s", "")<CR><CR>
|
以上是作者推荐的快捷键映射,但实际使用中用不到这么多,我进行筛选以下配置如下。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| "Yggdroot/LeaderF "按键映射前缀: <leader>f。 "文件搜索。 nnoremap <silent> <leader>ff :Leaderf file<CR> "历史打开过的文件。 nnoremap <silent> <leader>fm :Leaderf mru<CR> "Buffer。 nnoremap <silent> <leader>fb :Leaderf buffer<CR> "函数搜索(仅当前文件里)。 nnoremap <silent> <leader>fF :Leaderf function<CR> "grep模糊搜索。 nnoremap <silent> <leader>fg :Leaderf rg<CR> "搜索行。 nnoremap <silent> <leader>fl :Leaderf line<CR>
"通过Leaderf rg在当前缓存中搜索光标下的字符串。 noremap <leader>f<c-b> :<C-U><C-R>=printf("Leaderf! rg --current-buffer -e %s ", expand("<cword>"))<CR><CR> "通过Leaderf rg搜索光标下的字符串。 noremap <leader>f<c-f> :<C-U><C-R>=printf("Leaderf! rg -e %s ", expand("<cword>"))<CR><CR> "打开最近一次Leaderf rg搜索窗口。 noremap <leader>fr :<C-U>Leaderf! rg --recall<CR>
"搜索当前光标下函数引用,如果搜索结果只有一个则直接跳转。 noremap <leader>fc :<C-U><C-R>=printf("Leaderf! gtags -r %s --auto-jump", expand("<cword>"))<CR><CR> "搜索当前光标下函数定义,如果搜索结果只有一个则直接跳转。 noremap <leader>fd :<C-U><C-R>=printf("Leaderf! gtags -d %s --auto-jump", expand("<cword>"))<CR><CR> "打开上一次gtags搜索窗口。 noremap <leader>fR :<C-U><C-R>=printf("Leaderf! gtags --recall %s", "")<CR><CR> "跳转到下一个搜索结果。 noremap <leader>fn :<C-U><C-R>=printf("Leaderf gtags --next %s", "")<CR><CR> "跳转到上一个搜索结果。 noremap <leader>fp :<C-U><C-R>=printf("Leaderf gtags --previous %s", "")<CR><CR>
|