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

Yggdroot · · 1960 次点击 · 开始浏览    置顶
这是一个创建于 的主题,其中的信息可能已经有所发展或是发生改变。

## 前言 ## 上一篇文章《[让人相见恨晚的vim插件:模糊查找神器LeaderF](https://studygolang.com/topics/3458)》概括性的介绍了[LeaderF](https://github.com/Yggdroot/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也添加了自下而上显示搜索结果的功能: ![LeaderF_reverse_order](https://l.ruby-china.com/photo/2018/43bf65dd-4891-457d-9e62-46dd0d43dcb1.gif!large) 只需要在命令后面加上`--reverse`即可,或者也可以一劳永逸,在vimrc里面加上 `let g:Lf_ReverseOrder = 1` 。 ## And 模式 ## LeaderF支持用空格(可以用`g:Lf_AndDelimiter`来修改)作为And操作符来进行模糊匹配。当匹配已经匹配到字符串末尾时,可以通过敲空格和一个子串来匹配字符串的前面部分,进行快速过滤。 **NOTE:** 空格分隔的每个子串都是对整个字符串的模糊匹配,而不是精确匹配。 ![And模式](https://l.ruby-china.com/photo/2018/12784bd8-ff20-481a-8cba-1523ae275452.gif!large) ## 模糊匹配历史 ## 可以通过上下键来翻看模糊匹配历史: ![翻看历史](https://l.ruby-china.com/photo/2018/ef874a77-05ce-470d-829e-4351a3286af0.gif!large) ## 总结 ## LeaderF精益求精,永无止境。

有疑问加站长微信联系(非本文作者)

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

1960 次点击  
加入收藏 微博
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传