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

前言

上一篇文章《讓人相見恨晚的vim插件:模糊查找神器LeaderF》歸納性的介紹了LeaderF的基本功能,本篇對LeaderF的新功能作一下介紹。git

統一的命令接口

隨着LeaderF功能的不斷增多,LeaderF的命令也在不斷的增長,給開發和使用都帶來一些不便。因而,LeaderF提供了一個統一的命令接口,就像shell命令同樣,不一樣的命令選項組合,帶來不一樣的功能。
能夠經過:Leaderf -h來查看具體使用方法。github

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的命令了。例如:shell

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

每一個子命令都有專有的命令選項,能夠用:Leaderf <subcommand> -h來查看。例如,Leaderf mru -h:vim

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也添加了自下而上顯示搜索結果的功能: bash

LeaderF_reverse_order

只須要在命令後面加上--reverse便可,或者也能夠一勞永逸,在vimrc裏面加上 let g:Lf_ReverseOrder = 1ui

And 模式

LeaderF支持用空格(能夠用g:Lf_AndDelimiter來修改)做爲And操做符來進行模糊匹配。當匹配已經匹配到字符串末尾時,能夠經過敲空格和一個子串來匹配字符串的前面部分,進行快速過濾。
NOTE: 空格分隔的每一個子串都是對整個字符串的模糊匹配,而不是精確匹配。this

And模式

模糊匹配歷史

能夠經過上下鍵來翻看模糊匹配歷史: spa

翻看歷史

總結

LeaderF精益求精,永無止境。插件

相關文章
相關標籤/搜索