Convert Figma logo to code with AI

Yggdroot logoLeaderF

An efficient fuzzy finder that helps to locate files, buffers, mrus, gtags, etc. on the fly for both vim and neovim.

2,166
185
2,166
58

Top Related Projects

9,849

fzf :heart: vim

Find, Filter, Preview, Pick. All lua, all the time.

Active fork of kien/ctrlp.vim—Fuzzy file, buffer, mru, tag, etc finder.

:dragon: Dark powered asynchronous unite all interfaces for Neovim/Vim8

:clap: Modern performant fuzzy picker, tree-sitter highlighting, and more, for both Vim and NeoVim

⌨️ Fast file navigation for Neovim and Vim

Quick Overview

LeaderF is a fast and efficient fuzzy finder plugin for Vim and Neovim. It provides an intuitive interface for searching files, buffers, mru, tags, and more within your project, making navigation and file management in Vim significantly easier and faster.

Pros

  • Extremely fast and efficient, even for large projects
  • Highly customizable with numerous options and mappings
  • Supports multiple search modes (fuzzy, regex, full path)
  • Extensible architecture allowing for custom source definitions

Cons

  • Requires Python support in Vim/Neovim
  • Learning curve for advanced features and customizations
  • May conflict with other fuzzy finder plugins if not configured properly
  • Some users report occasional performance issues with very large projects

Code Examples

  1. Basic file search:
" Open LeaderF file search
nnoremap <leader>f :Leaderf file<CR>
  1. Search for buffers:
" Open LeaderF buffer search
nnoremap <leader>b :Leaderf buffer<CR>
  1. Search for tags in the current buffer:
" Open LeaderF tag search for current buffer
nnoremap <leader>t :Leaderf bufTag<CR>
  1. Custom mapping for searching in a specific directory:
" Search for files in the 'src' directory
nnoremap <leader>s :Leaderf file ~/projects/myproject/src<CR>

Getting Started

  1. Install LeaderF using your preferred Vim plugin manager. For example, with vim-plug:
Plug 'Yggdroot/LeaderF', { 'do': ':LeaderfInstallCExtension' }
  1. Add basic configuration to your .vimrc or init.vim:
" Don't show the help in normal mode
let g:Lf_HideHelp = 1
let g:Lf_UseCache = 0
let g:Lf_UseVersionControlTool = 0
let g:Lf_IgnoreCurrentBufferName = 1

" Popup mode
let g:Lf_WindowPosition = 'popup'
let g:Lf_PreviewInPopup = 1

" Show icons
let g:Lf_ShowDevIcons = 1

" Keymapping
let g:Lf_ShortcutF = "<leader>ff"
noremap <leader>fb :<C-U><C-R>=printf("Leaderf buffer %s", "")<CR><CR>
noremap <leader>fm :<C-U><C-R>=printf("Leaderf mru %s", "")<CR><CR>
noremap <leader>ft :<C-U><C-R>=printf("Leaderf bufTag %s", "")<CR><CR>
noremap <leader>fl :<C-U><C-R>=printf("Leaderf line %s", "")<CR><CR>
  1. Restart Vim and run :LeaderfInstallCExtension to install the C extension for better performance.

Competitor Comparisons

9,849

fzf :heart: vim

Pros of fzf.vim

  • Lightweight and fast, utilizing the power of fzf
  • Extensive integration with various Vim plugins and features
  • Highly customizable with a wide range of options and mappings

Cons of fzf.vim

  • Requires external dependencies (fzf)
  • Steeper learning curve for advanced customization
  • Less out-of-the-box functionality compared to LeaderF

Code Comparison

LeaderF:

" Basic file search
nnoremap <leader>f :LeaderfFile<CR>

" Function search
nnoremap <leader>fu :LeaderfFunction<CR>

" Buffer search
nnoremap <leader>b :LeaderfBuffer<CR>

fzf.vim:

" Basic file search
nnoremap <leader>f :Files<CR>

" Function search (requires ctags)
nnoremap <leader>fu :Tags<CR>

" Buffer search
nnoremap <leader>b :Buffers<CR>

Both plugins offer similar functionality for searching files, functions, and buffers. LeaderF provides more built-in features, while fzf.vim relies on external tools and offers greater flexibility in terms of customization and integration with other plugins.

Find, Filter, Preview, Pick. All lua, all the time.

Pros of telescope.nvim

  • Built specifically for Neovim, offering better integration and performance
  • Highly extensible with a rich plugin ecosystem
  • More modern UI with preview windows and customizable layouts

Cons of telescope.nvim

  • Steeper learning curve due to its extensive configuration options
  • Requires Neovim 0.5+ and Lua knowledge for advanced customization

Code Comparison

telescope.nvim:

require('telescope').setup{
  defaults = {
    mappings = {
      i = {
        ["<C-j>"] = "move_selection_next",
        ["<C-k>"] = "move_selection_previous",
      }
    }
  }
}

LeaderF:

let g:Lf_ShortcutF = '<C-P>'
let g:Lf_WindowPosition = 'popup'
let g:Lf_PreviewInPopup = 1

Both plugins offer powerful fuzzy finding capabilities, but telescope.nvim is more tailored for Neovim users who prefer a modern, extensible solution. LeaderF, on the other hand, provides a more straightforward setup and works with both Vim and Neovim, making it a solid choice for users who prioritize simplicity and cross-editor compatibility.

Active fork of kien/ctrlp.vim—Fuzzy file, buffer, mru, tag, etc finder.

Pros of ctrlp.vim

  • Lightweight and fast for small to medium-sized projects
  • Extensive customization options and mappings
  • Well-established with a large user base and community support

Cons of ctrlp.vim

  • Performance can degrade in large projects or with many files
  • Less modern interface compared to newer alternatives
  • Limited built-in functionality for advanced searching

Code Comparison

ctrlp.vim:

let g:ctrlp_map = '<c-p>'
let g:ctrlp_cmd = 'CtrlP'
let g:ctrlp_working_path_mode = 'ra'
let g:ctrlp_user_command = ['.git', 'cd %s && git ls-files -co --exclude-standard']

LeaderF:

let g:Lf_ShortcutF = '<c-p>'
let g:Lf_WorkingDirectoryMode = 'Ac'
let g:Lf_RootMarkers = ['.git', '.hg', '.svn']
let g:Lf_DefaultExternalTool = 'rg'

LeaderF offers a more modern and feature-rich alternative to ctrlp.vim. It provides better performance for large projects, a more visually appealing interface, and advanced searching capabilities out of the box. However, ctrlp.vim remains a solid choice for users who prefer a lightweight, highly customizable plugin with a familiar interface. The code comparison shows that both plugins can be configured similarly, but LeaderF offers more advanced options like external tool integration for improved performance.

:dragon: Dark powered asynchronous unite all interfaces for Neovim/Vim8

Pros of denite.nvim

  • Highly customizable and extensible through Python plugins
  • Supports asynchronous operations for better performance
  • Integrates well with other Neovim plugins and features

Cons of denite.nvim

  • Steeper learning curve due to its complexity and configuration options
  • Requires Python support, which may not be available in all Vim installations

Code Comparison

LeaderF:

let g:Lf_ShortcutF = '<C-P>'
let g:Lf_WindowPosition = 'popup'
let g:Lf_PreviewInPopup = 1

denite.nvim:

call denite#custom#var('file/rec', 'command', ['rg', '--files', '--glob', '!.git'])
nnoremap <C-p> :Denite file/rec<CR>
call denite#custom#option('default', {'split': 'floating'})

Both plugins offer fuzzy finding capabilities, but their configuration and usage differ. LeaderF provides a more straightforward setup, while denite.nvim offers greater flexibility through its custom sources and filters.

LeaderF is written in Python and Vim script, making it faster in some operations. However, denite.nvim's asynchronous nature can provide smoother performance for large projects.

Ultimately, the choice between LeaderF and denite.nvim depends on the user's needs for customization, performance, and integration with their existing Vim/Neovim setup.

:clap: Modern performant fuzzy picker, tree-sitter highlighting, and more, for both Vim and NeoVim

Pros of vim-clap

  • Built with Rust, offering better performance for large-scale searches
  • More visually appealing interface with floating window support
  • Extensible plugin architecture allowing for custom providers

Cons of vim-clap

  • Requires Rust to be installed for optimal performance
  • Relatively newer project with potentially less stability
  • Steeper learning curve for customization due to Rust backend

Code Comparison

vim-clap:

Clap files
Clap grep2
Clap registers

LeaderF:

Leaderf file
Leaderf rg
Leaderf buffer

Summary

Both vim-clap and LeaderF are powerful fuzzy finders for Vim/Neovim. vim-clap offers a modern interface and potentially faster performance due to its Rust backend, but requires additional setup. LeaderF is a more established project with a simpler setup process and broader language support. The choice between them depends on your specific needs, performance requirements, and willingness to manage dependencies.

⌨️ Fast file navigation for Neovim and Vim

Pros of Command-T

  • Written in C, offering faster performance for large codebases
  • Supports fuzzy matching across multiple file types
  • Integrates well with Vim's native features and keybindings

Cons of Command-T

  • Requires Ruby and compilation, which can be challenging on some systems
  • Less extensive feature set compared to LeaderF
  • Limited to file and buffer searching, while LeaderF offers more search types

Code Comparison

Command-T:

let g:CommandTMaxFiles = 500000
let g:CommandTMaxDepth = 15
nnoremap <silent> <Leader>t :CommandT<CR>

LeaderF:

let g:Lf_ShortcutF = '<C-P>'
let g:Lf_WorkingDirectoryMode = 'Ac'
let g:Lf_RootMarkers = ['.git', '.svn', '.hg', '.project', '.root']

Both plugins aim to improve file navigation in Vim, but they differ in implementation and features. Command-T focuses on speed and simplicity, while LeaderF offers a broader range of functionalities. LeaderF is written in Python, making it easier to install on most systems, whereas Command-T's C implementation may provide better performance for larger projects. LeaderF also includes additional features like MRU file search, tag search, and function search, making it more versatile for various development tasks.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

LeaderF

An efficient fuzzy finder that helps to locate files, buffers, mrus, gtags, etc. on the fly.

  • Written in Python.
  • Support fuzzy and regex searching.
  • Full-featured.
  • Well-designed fuzzy matching algorithm.
  • Extensible.

Changelog

Please see the CHANGELOG for a release history.

Wiki

Wiki.

Extensions

A list of community extensions can be found in the Extensions wiki.

Screenshots

Popup Mode

And Mode

Requirements

  • vim7.3 or higher. Only support 7.4.1126+ after v1.01.
  • Python2.7+ or Python3.1+.
  • To use the popup mode, neovim 0.5.0+ or vim 8.1.1615+ are required.

Installation

For vim-plug user:

Plug 'Yggdroot/LeaderF', { 'do': ':LeaderfInstallCExtension' }

Performance

LeaderF is already very fast. If you'd like better performance, install the C extension of the fuzzy matching algorithm, which is more than 10 times faster.
To install the C extension, firstly, make sure python2 and/or python3 commands are available on Linux/Unix/MacOS and py -2 and/or py -3 commands are available on Windows.

  • Install the C extension

    :LeaderfInstallCExtension
    

    There may be some errors 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

    :LeaderfUninstallCExtension
    

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

Usage

usage: Leaderf[!] [-h] [--reverse] [--stayOpen] [--input <INPUT> | --cword]
                  [--top | --bottom | --left | --right | --belowright | --aboveleft | --fullScreen | --popup]
                  [--nameOnly | --fullPath | --fuzzy | --regexMode] [--nowrap] [--next | --previous]
                  [--recall] [--popup-height <POPUP_HEIGHT>] [--popup-width <POPUP_WIDTH>] [--no-sort]
                  [--case-insensitive] [--auto-preview | --no-auto-preview]
                  
                  {file,tag,function,mru,searchHistory,cmdHistory,help,line,colorscheme,gtags,
                      self,bufTag,buffer,rg,filetype,command,window,quickfix,loclist,jumps}
                  ...

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
  --popup               the LeaderF window is a popup window or floating window
  --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.
  --recall              Recall last search. If the result window is closed, reopen it.
  --popup-height <POPUP_HEIGHT>
                        specifies the maximum height of popup window, only available in popup mode.
  --popup-width <POPUP_WIDTH>
                        specifies the width of popup window, only available in popup mode.
  --no-sort             do not sort the result.
  --case-insensitive    fuzzy search case insensitively.
  --auto-preview        open preview window automatically.
  --no-auto-preview     don't open preview window automatically.

subcommands:

  {file,tag,function,mru,searchHistory,cmdHistory,help,line,colorscheme,gtags,
      self,bufTag,buffer,rg,filetype,command,window,quickfix,loclist,jumps}
    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
    gtags               navigate tags using the gtags
    self                execute the commands of itself
    bufTag              navigate tags in the buffer
    buffer              search buffers
    rg                  grep using rg
    filetype            navigate the filetype
    command             execute built-in/user-defined Ex commands.
    window              search windows.
    quickfix            navigate the quickfix.
    loclist             navigate the location list.

If [!] is given, enter normal mode directly.

use :Leaderf <subcommand> -h to get specific help of subcommand, e.g., :Leaderf rg -h.

Once LeaderF is launched:

CommandDescription
<C-C>
<ESC>
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
<Tab>switch to normal mode
<C-V>
<S-Insert>
paste from clipboard
<C-U>clear the prompt
<C-W>delete the word before the cursor in the prompt
<C-J>move the cursor downward in the result window
<C-K>move the cursor upward in the result window
<Up>/<Down>recall last/next input pattern from history
<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
<C-\>show a prompt enable to choose split window method: vertical, horizontal, tabpage, etc
<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
<C-Up>scroll up in the popup preview window
<C-Down>scroll down in the popup preview window

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...
    

Popup Mode

Popup Mode is to open LeaderF in a popup window(vim 8.1.1615+) or floating window(nvim 0.4.2+).

To enable popup mode:

let g:Lf_WindowPosition = 'popup'

or add --popup after each subcommand, e.g.,

Leaderf file --popup

Customization

  • Change key bindings

    By default, <Up> and <Down> are used to recall last/next input pattern from history. If you want to use them to navigate the result list just like <C-K> and <C-J> :

    let g:Lf_CommandMap = {'<C-K>': ['<Up>'], '<C-J>': ['<Down>']}

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

  • Change the colors used in LeaderF

    let g:Lf_PopupPalette = {
        \  'light': {
        \      'Lf_hl_match': {
        \                'gui': 'NONE',
        \                'font': 'NONE',
        \                'guifg': 'NONE',
        \                'guibg': '#303136',
        \                'cterm': 'NONE',
        \                'ctermfg': 'NONE',
        \                'ctermbg': '236'
        \              },
        \      'Lf_hl_cursorline': {
        \                'gui': 'NONE',
        \                'font': 'NONE',
        \                'guifg': 'NONE',
        \                'guibg': '#303136',
        \                'cterm': 'NONE',
        \                'ctermfg': 'NONE',
        \                'ctermbg': '236'
        \              },
        \      },
        \  'dark': {
        \         ...
        \         ...
        \      }
        \  }
    

    All the highlight groups supported are defined in LeaderF/autoload/leaderf/colorscheme/popup/default.vim.

  • Change the default mapping of searching files command

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

  • Show icons (should install fonts from https://github.com/ryanoasis/nerd-fonts)

    Support commands: buffer,file,mru,window

    " Show icons, icons are shown by default
    let g:Lf_ShowDevIcons = 1
    " For GUI vim, the icon font can be specify like this, for example
    let g:Lf_DevIconsFont = "DroidSansM Nerd Font Mono"
    " If needs
    set ambiwidth=double
    

Configuration examples

" don't show the help in normal mode
let g:Lf_HideHelp = 1
let g:Lf_UseCache = 0
let g:Lf_UseVersionControlTool = 0
let g:Lf_IgnoreCurrentBufferName = 1
" popup mode
let g:Lf_WindowPosition = 'popup'
let g:Lf_StlSeparator = { 'left': "\ue0b0", 'right': "\ue0b2", 'font': "DejaVu Sans Mono for Powerline" }
let g:Lf_PreviewResult = {'Function': 0, 'BufTag': 0 }

let g:Lf_ShortcutF = "<leader>ff"
noremap <leader>fb :<C-U><C-R>=printf("Leaderf buffer %s", "")<CR><CR>
noremap <leader>fm :<C-U><C-R>=printf("Leaderf mru %s", "")<CR><CR>
noremap <leader>ft :<C-U><C-R>=printf("Leaderf bufTag %s", "")<CR><CR>
noremap <leader>fl :<C-U><C-R>=printf("Leaderf line %s", "")<CR><CR>

noremap <C-B> :<C-U><C-R>=printf("Leaderf! rg --current-buffer -e %s ", expand("<cword>"))<CR>
noremap <C-F> :<C-U><C-R>=printf("Leaderf! rg -e %s ", expand("<cword>"))<CR>
" search visually selected text literally
xnoremap gf :<C-U><C-R>=printf("Leaderf! rg -F -e %s ", leaderf#Rg#visual())<CR>
noremap go :<C-U>Leaderf! rg --recall<CR>

" should use `Leaderf gtags --update` first
let g:Lf_GtagsAutoGenerate = 0
let g:Lf_Gtagslabel = 'native-pygments'
noremap <leader>fr :<C-U><C-R>=printf("Leaderf! gtags -r %s --auto-jump", expand("<cword>"))<CR><CR>
noremap <leader>fd :<C-U><C-R>=printf("Leaderf! gtags -d %s --auto-jump", expand("<cword>"))<CR><CR>
noremap <leader>fo :<C-U><C-R>=printf("Leaderf! gtags --recall %s", "")<CR><CR>
noremap <leader>fn :<C-U><C-R>=printf("Leaderf gtags --next %s", "")<CR><CR>
noremap <leader>fp :<C-U><C-R>=printf("Leaderf gtags --previous %s", "")<CR><CR>

FAQ

https://github.com/Yggdroot/LeaderF/issues?q=label%3AFAQ+

License

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

:heart: Sponsor

If you like this software, please consider buying me a coffee.
https://github.com/Yggdroot/SponsorMe/blob/main/README.md#donate (捐赠的朋友最好备注一下自己的ID)