资讯专栏INFORMATION COLUMN

vim的模糊查找插件LeaderF新功能介绍

junnplus / 1531人阅读

摘要:前言上一篇文章让人相见恨晚的插件模糊查找神器概括性的介绍了的基本功能,本篇对的新功能做一下介绍。空格分隔的每个子串都是对整个字符串的模糊匹配,而不是精确匹配。

前言

上一篇文章《让人相见恨晚的vim插件:模糊查找神器LeaderF》概括性的介绍了LeaderF的基本功能,本篇对LeaderF的新功能做一下介绍。

统一的命令接口

随着LeaderF功能的不断增多,LeaderF的命令也在不断的增加,给开发和使用都带来一些不便。于是,LeaderF提供了一个统一的命令接口,就像shell命令一样,不同的命令选项组合,带来不同的功能。
可以通过:Leaderf -h来查看具体使用方法。

usage: Leaderf[!] [-h] [--reverse] [--stayOpen] [--input  | --cword]
                  [--top | --bottom | --left | --right | --belowright | --aboveleft | --fullScreen]
                  [--nameOnly | --fullPath | --fuzzy | --regexMode] [--nowrap]
                  {file,tag,function,mru,searchHistory,cmdHistory,help,line,colorscheme,self,bufTag,buffer,rg}
                  ...

optional arguments:
  -h, --help            show this help message and exit
  --reverse             show results in bottom-up order
  --stayOpen            don"t quit LeaderF after accepting an entry
  --input        specifies INPUT as the pattern inputted in advance
  --cword               current word under cursor is inputted in advance
  --top                 the LeaderF window is at the top of the screen
  --bottom              the LeaderF window is at the bottom of the screen
  --left                the LeaderF window is at the left of the screen
  --right               the LeaderF window is at the right of the screen
  --belowright          the LeaderF window is at the belowright of the screen
  --aboveleft           the LeaderF window is at the aboveleft of the screen
  --fullScreen          the LeaderF window takes up the full screen
  --nameOnly            LeaderF is in NameOnly mode by default
  --fullPath            LeaderF is in FullPath mode by default
  --fuzzy               LeaderF is in Fuzzy mode by default
  --regexMode           LeaderF is in Regex mode by default
  --nowrap              long lines in the LeaderF window won"t wrap

subcommands:

  {file,tag,function,mru,searchHistory,cmdHistory,help,line,colorscheme,self,bufTag,buffer,rg}
    file                search files
    tag                 navigate tags using the tags file
    function            navigate functions or methods in the buffer
    mru                 search most recently used files
    searchHistory       execute the search command in the history
    cmdHistory          execute the command in the history
    help                navigate the help tags
    line                search a line in the buffer
    colorscheme         switch between colorschemes
    self                execute the commands of itself
    bufTag              navigate tags in the buffer
    buffer              search buffers
    rg                  grep using rg

If [!] is given, enter normal mode directly.

这样就可以用:Leaderf [options]来执行LeaderF的命令了。例如:

Before Now
:LeaderfFile <=> :Leaderf file
:LeaderfBuffer <=> :Leaderf buffer
:LeaderfMru <=> :Leaderf mru
:LeaderfMruCwd <=> :Leaderf mru --cwd
...

每个子命令都有专有的命令选项,可以用:Leaderf -h来查看。例如,Leaderf mru -h:

usage: Leaderf[!] mru [-h] [--cwd] [--no-split-path] [--reverse] [--stayOpen]
                      [--input  | --cword]
                      [--top | --bottom | --left | --right | --belowright | --aboveleft | --fullScreen]
                      [--nameOnly | --fullPath | --fuzzy | --regexMode]
                      [--nowrap]

optional arguments:
  -h, --help       show this help message and exit

specific arguments:
  --cwd            search MRU in current working directory
  --no-split-path  do not split the path

common arguments:
  --reverse        show results in bottom-up order
  --stayOpen       don"t quit LeaderF after accepting an entry
  --input   specifies INPUT as the pattern inputted in advance
  --cword          current word under cursor is inputted in advance
  --top            the LeaderF window is at the top of the screen
  --bottom         the LeaderF window is at the bottom of the screen
  --left           the LeaderF window is at the left of the screen
  --right          the LeaderF window is at the right of the screen
  --belowright     the LeaderF window is at the belowright of the screen
  --aboveleft      the LeaderF window is at the aboveleft of the screen
  --fullScreen     the LeaderF window takes up the full screen
  --nameOnly       LeaderF is in NameOnly mode by default
  --fullPath       LeaderF is in FullPath mode by default
  --fuzzy          LeaderF is in Fuzzy mode by default
  --regexMode      LeaderF is in Regex mode by default
  --nowrap         long lines in the LeaderF window won"t wrap

If [!] is given, enter normal mode directly.
自下而上显示结果

好多从ctrlp.vim转过来的朋友说不习惯LeaderF自上而下显示结果的方式,想要LeaderF也能像ctrlp一样自下而上(最优结果在最下面)显示结果,为了回馈各位朋友对LeaderF的支持,现在LeaderF也添加了自下而上显示搜索结果的功能:

只需要在命令后面加上--reverse即可,或者也可以一劳永逸,在vimrc里面加上
let g:Lf_ReverseOrder = 1

And 模式

LeaderF支持用空格(可以用g:Lf_AndDelimiter来修改)作为And操作符来进行模糊匹配。当匹配已经匹配到字符串末尾时,可以通过敲空格和一个子串来匹配字符串的前面部分,进行快速过滤。
NOTE: 空格分隔的每个子串都是对整个字符串的模糊匹配,而不是精确匹配。

模糊匹配历史

可以通过上下键来翻看模糊匹配历史:

总结

LeaderF精益求精,永无止境。

文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。

转载请注明本文地址:https://www.ucloud.cn/yun/25050.html

相关文章

  • 让人相见恨晚vim插件模糊查找神器LeaderF

    摘要:是什么是一个用写的插件,可以在成千上万数十万个文件中,通过模糊查找的方式,快速找到目标文件。它还有很多衍生功能快速打开或定位某个最近使用的文件包括函数类变量等命令历史文件中的某一行的等等。友情链接,也許是最好的模糊查詢插件 提到vim的模糊查找插件,很多人第一反应是ctrlp.vim,ctrlp知名度很高,但跟其它的同类插件相比,它的唯一优点是用vimL编写(这让它的性能是所有同类插件...

    Near_Li 评论0 收藏0
  • `Leaderf gtags`:模糊匹配与最强静态符号索引工具完美结合

    摘要:也就是,是一个非常强大的源码符号索引工具。韦大的中符号索引篇对有比较详细的介绍,本文再做一些补充。的最新版本已经是,该版本了韦大文中提到的下面文件名大小写的。 Gtags Gtags也就是GNU GLOBAL,是一个非常强大的源码符号索引工具。它通过建立索引数据库,不但可以查找函数的定义,还可以查找函数的所有引用(被调用的地方);而且它还可以增量地更新索引数据库,当代码有所改变时,它可...

    hsluoyz 评论0 收藏0
  • 如何让 Vim 美观又实用(1)

    摘要:比如,由于的一些命令,比如默认是在当前目录下进行,实际就变成了在项目根目录下搜索。如果使用,那么也是必不可少。比如一个比较实用的就是用查找当前光标下的词。今天就先讲这么多了,下一篇可能更多讲讲如何配置更美观的一些小细节。 我学习计算机不久就开始用了 vim,到现在也三四年了,且算是对 vim 有了一定的控制力。在这里分享一下使用过程中的一些心路历程,说实话,要留意的小地方有很多,但是由...

    wthee 评论0 收藏0
  • VIM模糊搜索神器FZF集成用法 - 从简单到高级

    摘要:比如下表是它可用的所有选项是一个函数,用来创建自己的自动补全功能。如果第一个参数是一个命令字符或一个那么它会被用作对于高级用户,可以传入一个字典选项。希望大家可以结合创造出更多的使用方法。 FZF and VIM 前言 fzf本身并不是一个vim 插件,本来作者只提供了基本的wrapper函数(比如fzf#run). 但后来作者发现很多人并不熟悉VIMScript, 所以就创建一个默认...

    OldPanda 评论0 收藏0
  • VIM模糊搜索神器FZF集成用法 - 从简单到高级

    摘要:比如下表是它可用的所有选项是一个函数,用来创建自己的自动补全功能。如果第一个参数是一个命令字符或一个那么它会被用作对于高级用户,可以传入一个字典选项。希望大家可以结合创造出更多的使用方法。 FZF and VIM 前言 fzf本身并不是一个vim 插件,本来作者只提供了基本的wrapper函数(比如fzf#run). 但后来作者发现很多人并不熟悉VIMScript, 所以就创建一个默认...

    ?xiaoxiao, 评论0 收藏0

发表评论

0条评论

junnplus

|高级讲师

TA的文章

阅读更多
最新活动
阅读需要支付1元查看
<