LeaderF – 超级好用的VIM全局搜索插件

LeaderF – 超级好用的VIM全局搜索插件超级好用的VIM全局搜索插件。

This plugin is mainly used for locating files, buffers, mrus, tags in large project.

  • Written in Python.
  • Support fuzzy and regex searching.
  • Manage buffers and mrus.
  • Open multiple files at once.
  • Extensible.

Screenshots

NameOnly Mode

FullPath Mode

Requirements

  • vim7.3 or higher. Only support vim7.4.330 or higher after v1.01.
  • vim compiled with Python support, you can check by using echo has('python') or echo has('python3') to see if the result is 1; Make sure that your python2 version is Python 2.7 or higher and python3 version is Python 3.1 or higher.

Installation

To install this plugin just put the plugin files in your ~/.vim (Linux) or ~/vimfiles (Windows).
For Vundle user, just add Plugin 'Yggdroot/LeaderF' to your .vimrc.

Performance

LeaderF is already very fast. If you want better performance, install the C extension of the fuzzy matching algorithm, which is more than 10 times faster. To install the C extension, follow the below:

  • On Linux/Unix/MacOS:

    First, make sure python and/or python3 commands are available.
    Then run the installation script:

    cd ~/.vim/bundle/LeaderF
    ./install.sh

    Uninstall the C extension:

     ./install.sh --reverse
    

    If you are using vim-plug:

     Plug 'Yggdroot/LeaderF', { 'do': './install.sh' }
    
  • On Windows:

    First, make sure py and/or py -3 commands are available.
    Then run the installation script:

    cd ~\.vim\bundle\LeaderF
    .\install.bat

    There may be some error during the installation, please google the error messages to resolve it.

    Uninstall the C extension:

     .\install.bat --reverse
    

    If you are using vim-plug:

     Plug 'Yggdroot/LeaderF', { 'do': '.\install.bat' }
    

After running any command of LeaderF, check the value of echo g:Lf_fuzzyMatch_C, if the value is 1, it means the C extension is loaded sucessfully.

Usage

Command Description
:LeaderfFile
<leader>f
search files
:LeaderfFile [directory] search files under the directory specified
:LeaderfFileFullScreen search files, LeaderF window take up full screen
:LeaderfBuffer
<leader>b
search listed buffers
:LeaderfBufferAll search all buffers
:LeaderfMru search most recently used files
:LeaderfMruCwd search MRU in current working directory
:LeaderfTag navigate tags using the tags file
:LeaderfBufTag navigate tags in current buffer
:LeaderfBufTagAll navigate tags in all listed buffers
:LeaderfFunction navigate functions or methods in current buffer
:LeaderfFunctionAll navigate functions or methods in all listed buffers
:LeaderfLine search a line in current buffer
:LeaderfLineAll search a line in all listed buffers
:LeaderfHistoryCmd execute the command in the history
:LeaderfHistorySearch execute the search command in the history
:LeaderfSelf execute the commands of itself
:LeaderfHelp navigate the help tags
:LeaderfColorscheme switch between colorschemes

Once LeaderF is launched:

Command Description
<C-C> quit from LeaderF
<C-R> switch between fuzzy search mode and regex mode
<C-F> switch between full path search mode and name only search mode
<ESC> switch to normal mode
<C-V>
<S-Insert>
paste from clipboard
<C-U> clear the prompt
<C-J>
<Down>
move the cursor downward in the result window
<C-K>
<Up>
move the cursor upward in the result window
<2-LeftMouse>
<CR>
open the file under cursor or selected(when multiple files are selected)
<C-X> open in horizontal split window
<C-]> open in vertical split window
<C-T> open in new tabpage
<F5> refresh the cache
<C-LeftMouse>
<C-S>
select multiple files
<S-LeftMouse> select consecutive multiple files
<C-A> select all files
<C-L> clear all selections
<BS> delete the preceding character in the prompt
<Del> delete the current character in the prompt
<Home> move the cursor to the begin of the prompt
<End> move the cursor to the end of the prompt
<Left> move the cursor one character to the left in the prompt
<Right> move the cursor one character to the right in the prompt
<C-P> preview the result

Input formats:

  • In NameOnly mode (fuzzy)

    'abc' is interpreted as vim’s regexp 'a.\{-}b.\{-}c'.
    If the first character you input is ';', then the searching will be the same as in FullPath mode.
    If you input string as 'abc;def', then 'abc' will match the file name and 'def' will match the directory name.

  • In FullPath mode (fuzzy)

    Same as in NameOnly mode except that the pattern will match the full path but not the file name only.

  • In Regexp mode

    The input string is the same as the Vim’s regexp.

Customization

  • Change key bindings

    By default, <ESC> is the shortcut key to switch to normal mode, if you want to change it to be ‘Quit from LeaderF’:

    let g:Lf_CommandMap = {'<C-C>': ['<Esc>', '<C-C>']}

  • Customize the statusline

    Please refer to here.

  • Change the highlight of matched string

    highlight Lf_hl_match gui=bold guifg=Blue cterm=bold ctermfg=21
    highlight Lf_hl_matchRefine  gui=bold guifg=Magenta cterm=bold ctermfg=201

  • Change the default mapping of searching files command

    e.g. let g:Lf_ShortcutF = '<C-P>'

License

This plugin is released under the Apache License, Version 2.0 (the “License”).

今天的文章LeaderF – 超级好用的VIM全局搜索插件分享到此就结束了,感谢您的阅读。

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
如需转载请保留出处:http://bianchenghao.cn/23449.html

(0)
编程小号编程小号

相关推荐

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注