Home - Yggdroot/test GitHub Wiki

Skip to content

Search or jump to…

Pull requests Issues Marketplace Explore

@Yggdroot 32 850 73 Yggdroot/LeaderF Code Issues 11 Pull requests 0 Projects 0 Wiki Security Insights Settings An asynchronous fuzzy finder which is used to quickly locate files, buffers, mrus, tags, etc. in large project. fuzzy-search fuzzy-matching fuzzyfinder mru ctags vim fuzzy gtags ripgrep 473 commits 2 branches 13 releases 15 contributors Apache-2.0 @Yggdroot Yggdroot enhance the guess algorithm … Latest commit 2320e6f 6 hours ago Type Name Latest commit message Commit time autoload enhance the guess algorithm 6 hours ago doc fix issue #360 and #366 3 days ago plugin auto update gtags no matter what g:Lf_GtagsAutoGenerate is 5 months ago syntax fix issue #191 6 months ago .gitignore ignore *.swp and doc/tags 5 years ago CHANGELOG.md update readme and changelog 5 months ago ISSUE_TEMPLATE.md add code to help debug issues 8 months ago LICENSE change license to Apache License, Version 2.0 3 years ago README.md add "--no-messages" for Leaderf rg 5 months ago install.bat add fuzzyEngine to fully take advantage of the cpu cores last year install.sh fix issue #225: install.sh failed on Windows10(msys64) last year README.md LeaderF This plugin is mainly used for locating files, buffers, mrus, ctags, gtags, etc. in large project.

Written in Python. Support fuzzy and regex searching. Manage buffers and mrus. Open multiple files at once. Extensible. Changelog Please see the CHANGELOG for a release history.

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 python2 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 -2 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. For example, "error: Unable to find vcvarsall.bat", you can turn to here for help.

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 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,gtags} ...

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 --next Jump to the next result. --previous Jump to the previous result.

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(ripgrep) gtags navigate tags using the gtags

If [!] is given, enter normal mode directly. use :Leaderf -h to get specific help of subcommand, e.g., :Leaderf rg -h

usage: Leaderf[!] rg [-h] [-A ] [-B ] [-C ] [--context-separator ] [-e ...] [-F] [-i] [-L] [-P] [-S] [-s] [-v] [-w] [-x] [--hidden] [--no-config] [--no-ignore] [--no-ignore-global] [--no-ignore-parent] [--no-ignore-vcs] [--no-messages] [--no-pcre2-unicode] [-E ] [-M ] [-m ] [--max-depth ] [--max-filesize <NUM+SUFFIX?>] [--path-separator ] [--sort ] [--sortr ] [-f ...] [-g ...] [--iglob ...] [--ignore-file ...] [--type-add <TYPE_SPEC>...] [-t ...] [-T ...] [--current-buffer | --all-buffers] [--recall] [--append] [--match-path] [--wd-mode ] [--reverse] [--stayOpen] [--input | --cword] [--top | --bottom | --left | --right | --belowright | --aboveleft | --fullScreen] [--nameOnly | --fullPath | --fuzzy | --regexMode] [--nowrap] [--next | --previous] [ [ ...]]

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

specific arguments: -A , --after-context Show NUM lines after each match. -B , --before-context Show NUM lines before each match. -C , --context Show NUM lines before and after each match. --context-separator The string used to separate non-contiguous context lines in the output. -e ..., --regexp ... A pattern to search for. This option can be provided multiple times, where all patterns given are searched. -F, --fixed-strings Treat the pattern as a literal string instead of a regular expression. -i, --ignore-case Searches case insensitively. -L, --follow Follow symbolic links while traversing directories. -P, --pcre2 When this flag is present, rg will use the PCRE2 regex engine instead of its default regex engine. -S, --smart-case Searches case insensitively if the pattern is all lowercase, case sensitively otherwise. -s, --case-sensitive Searches case sensitively. -v, --invert-match Invert matching. Show lines that do not match the given patterns. -w, --word-regexp Only show matches surrounded by word boundaries. This is roughly equivalent to putting \b before and after all of the search patterns. -x, --line-regexp Only show matches surrounded by line boundaries. --hidden Search hidden files and directories. By default, hidden files and directories are skipped. --no-config Never read configuration files. When this flag is present, rg will not respect the RIPGREP_CONFIG_PATH environment variable. --no-ignore Don't respect ignore files (.gitignore, .ignore, etc.). This implies --no-ignore-parent and --no-ignore-vcs. --no-ignore-global Don't respect ignore files that come from 'global' sources such as git's core.excludesFile configuration option (which defaults to $HOME/.config/git/ignore). --no-ignore-parent Don't respect ignore files (.gitignore, .ignore, etc.) in parent directories. --no-ignore-vcs Don't respect version control ignore files (.gitignore, etc.). --no-messages Suppress all error messages related to opening and reading files. --no-pcre2-unicode When PCRE2 matching is enabled, this flag will disable Unicode mode, which is otherwise enabled by default. -E , --encoding Specify the text encoding that rg will use on all files searched. -M , --max-columns Don't print lines longer than this limit in bytes. -m , --max-count Limit the number of matching lines per file searched to NUM. --max-depth Limit the depth of directory traversal to NUM levels beyond the paths given. --max-filesize <NUM+SUFFIX?> Ignore files larger than NUM in size. This does not apply to directories. --path-separator Set the path separator to use when printing file paths. --sort This flag enables sorting of results in ascending order. --sortr This flag enables sorting of results in descending order. -f ..., --file ... Search for patterns from the given file, with one pattern per line.(This option can be provided multiple times.) -g ..., --glob ... Include or exclude files and directories for searching that match the given glob.(This option can be provided multiple times.) --iglob ... Include or exclude files and directories for searching that match the given glob. Globs are matched case insensitively.(This option can be provided multiple times.) --ignore-file ... Specifies a path to one or more .gitignore format rules files. --type-add <TYPE_SPEC>... Add a new glob for a particular file type. -t ..., --type ... Only search files matching TYPE. Multiple type flags may be provided. -T ..., --type-not ... Do not search files matching TYPE. Multiple type-not flags may be provided. A file or directory to search. Directories are searched recursively. Paths specified on the command line override glob and ignore rules. --current-buffer Searches in current buffer. --all-buffers Searches in all listed buffers. --recall Recall last search. If the result window is closed, reopen it. --append Append to the previous search results. --match-path Match the file path when fuzzy searching. --wd-mode Specify the working directory mode, value has the same meaning as g:Lf_WorkingDirectoryMode.

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 --next Jump to the next result. --previous Jump to the previous result.

If [!] is given, enter normal mode directly. You can customize some handy maps, e.g.,

" search word under cursor, the pattern is treated as regex, and enter normal mode directly noremap :=printf("Leaderf! rg -e %s ", expand("")) " search word under cursor, the pattern is treated as regex, " append the result to previous search results. noremap :=printf("Leaderf! rg --append -e %s ", expand("")) " search word under cursor literally only in current buffer noremap :=printf("Leaderf! rg -F --current-buffer -e %s ", expand("")) " search visually selected text literally, don't quit LeaderF after accepting an entry xnoremap gf :=printf("Leaderf! rg -F --stayOpen -e %s ", leaderf#Rg#visual()) " recall last search. If the result window is closed, reopen it. noremap go :Leaderf! rg --stayOpen --recall Once LeaderF is launched:

Command Description quit from LeaderF switch between fuzzy search mode and regex mode switch between full path search mode and name only search mode switch to normal mode paste from clipboard clear the prompt move the cursor downward in the result window move the cursor upward in the result window / recall last/next input pattern from history <2-LeftMouse> open the file under cursor or selected(when multiple files are selected) open in horizontal split window <C-]> open in vertical split window open in new tabpage refresh the cache select multiple files select consecutive multiple files select all files clear all selections delete the preceding character in the prompt delete the current character in the prompt move the cursor to the begin of the prompt move the cursor to the end of the prompt move the cursor one character to the left in the prompt move the cursor one character to the right in the prompt preview the result Input formats:

In NameOnly mode (fuzzy mode)

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 mode)

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.

Smart Case:

If the characters in search pattern are all lowercase, the matching is case-insensitive. If the search pattern contains uppercase characters, all lowercase characters still are matched case-insensitively, the uppercase characters can only match upper case. So uppercase characters can speed up the narrowing down of the searching result.

e.g., input abcDef,it can match the following strings:

abcDef AbcDef abcDEf aBcDeF but can not match the strings such as:

abcdef Abcdef Note: abc and ef are still case-insensitive.

And operator:

In fuzzy mode, using ' '(space) as the and operator, the candidate lines should fuzzily match all the substrings separated by space.

e.g., input abc def gh,it can match the following strings:

...a.b.c...d.e.f...g.h... ...a.b.c...g.h...d.e.f... ...a.d..e.g.b.c...h..f... ...gh...def...abc... Customization Change key bindings

By default, and are used to recall last/next input pattern from history. If you want to use them to navigate the result list just like and :

let g:Lf_CommandMap = {'': [''], '': ['']}

for more detail, please refer to :h g:Lf_CommandMap.

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 = ''

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

© 2019 GitHub, Inc. Terms Privacy Security Status Help Contact GitHub Pricing API Training Blog About

⚠️ **GitHub.com Fallback** ⚠️