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

前言

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

统一的命令接口

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

usage: Leaderf[!] [-h] [--reverse] [--stayOpen] [--input <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 <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 <subcommand> [options]来执行LeaderF的命令了。例如:

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

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

usage: Leaderf[!] mru [-h] [--cwd] [--no-split-path] [--reverse] [--stayOpen]
                      [--input <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 <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也添加了自下而上显示搜索结果的功能:
vim的模糊查找插件LeaderF新功能介绍

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

And 模式

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

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

模糊匹配历史

可以通过上下键来翻看模糊匹配历史:
vim的模糊查找插件LeaderF新功能介绍

总结

LeaderF精益求精,永无止境。

vim

相关推荐