[Vim] 插件之 LeaderF

1. LeaderF 介绍

LeaderF 是一个问世很长时间的 Vim 插件了,可是我直到最近才发现它,大有相见恨晚之感。它的基本功能是提供了文件、buffers、mrus(most recently used)、tags 的检索,速度很快且是异步查找。检索过程中支持正则表达式、模糊匹配,并可以实时的过滤结果。

LeaderF 是用 Python 实现的,因此需要 Vim 支持 Python Feature。可以通过 vim --version 来查看是否支持 Python。

2. LeaderF 的安装

推荐使用 vundle 进行安装,vundle 的安装配置请参考其他资料。在 .vimrc 配置文件里增加下面的配置:

Bundle 'Yggdroot/LeaderF'
3. 常用功能
  • 检索文件:
<leader>f
  • 检索 buffer:
<leader>b
  • 在 LeaderF 运行起来以后(在正常检索的模式下),可以执行下面的一些操作:
<C-C>, <ESC> : 退出 LeaderF. 
<C-R> : 在模糊匹配和正则式匹配之间切换
<C-F> : 在全路径搜索和名字搜索之间切换
<Tab> : 在检索模式和选择模式之间切换
<C-J>, <C-K> : 在结果列表里选择
<C-X> : 在水平窗口打开
<C-]> : 在垂直窗口打开
<C-T> : 在新标签打开
<C-P> : 预览结果
  • 在 LeaderF 检索文件的模式下,如果按 Tab 进入选择列表之后,会有其他的快捷键,可以通过 F1 来查看。
  • 集成 ripgrep 进行检索是 LeaderF 很强大的一个功能,rg 是异步的,比 vimgrep 要好很多。而且,对结果可以进行二次过滤:
:LeaderfRgRecall 显示上次 rg 的结果
:Leaderf rg 实时检索
:Leaderf rg [option] 后面的 [option] 和 rg 的语法保持一致
4. 参考资料
Standard Unix-style glob syntax is supported:

    ? matches any single character. (If the literal_separator option is enabled, then ? can never match a path separator.)
    * matches zero or more characters. (If the literal_separator option is enabled, then * can never match a path separator.)
    ** recursively matches directories but are only legal in three situations. First, if the glob starts with **/, then it matches all directories. For example, **/foo matches foo and bar/foo but not foo/bar. Secondly, if the glob ends with /**, then it matches all sub-entries. For example, foo/** matches foo/a and foo/a/b, but not foo. Thirdly, if the glob contains /**/ anywhere within the pattern, then it matches zero or more directories. Using ** anywhere else is illegal (N.B. the glob ** is allowed and means "match everything").
    {a,b} matches a or b where a and b are arbitrary glob patterns. (N.B. Nesting {...} is not currently allowed.)
    [ab] matches a or b where a and b are characters. Use [!ab] to match any character except for a and b.
    Metacharacters such as * and ? can be escaped with character class notation. e.g., [*] matches *.

  • 1
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值