vim-niffler


Ⅰ. 插件描述

Fuzzy file finder for Vim

Ⅱ. 基本信息

创建日期:  2014-07-07
使用用户:  3
Github星:  6
插件作者:  Pierre-Guy Douyon

Ⅲ. 安装方法

使用Vundle管理器安装

在你的.vimrc下添加:
Plugin 'pgdouyon/vim-niffler'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall

对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。

使用NeoBundle管理器安装

在你的.vimrc下添加:
NeoBundle 'pgdouyon/vim-niffler'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall

使用VimPlug管理器安装

在你的.vimrc下添加:
Plug 'pgdouyon/vim-niffler'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall

使用Pathogen管理器安装

在终端中运行以下命令:
cd ~/.vim/bundle
git clone https://github.com/pgdouyon/vim-niffler

Ⅳ. 文档说明

Niffler

"These're nifflers," said Hagrid, when the class had gathered around. "Yeh
find 'em down mines mostly. They like sparkly stuff...useful little
treasure detectors."

Nifflers are fluffy, mole-like creatures that like to dig for treasure.
Vim-Niffler, on the other hand, is a fast, lightweight, fuzzy, file finder for
Vim and is heavily inspired by [FZF][].

I made Vim-Niffler because all the other fuzzy file finders I tried were either
too slow without caching (Unite, CtrlP), too complicated (Unite), had a hideous
codebase (CtrlP), or didn't support opening the fuzzy finder in the current
window (FZF).

If I had known about g:ctrlp_user_command="ag %s" and g:ctrlp_use_caching=0
I probably would have never made Niffler, but now that I have it's nice to have
a small, legible codebase that makes adding new features/changing core
functionality a breeze.

Usage

Niffler differs from other fuzzy file finders in that it doesn't perform a
fuzzy search by default. Instead it searches for an exact match of the text
typed but you can insert a "fuzzy character" to specify which part of the query
should match any string of characters. This works exactly like the "*"
wildcard character in most shells:

  • izzbu will match fizzbuzz but not fizzbazbuzz
  • izz*bu will match fizzbuzz and fizzbazbuzz

The default fuzzy char is * but can be changed with g:niffler_fuzzy_char

The beginning and end of the query are fuzzy by default but you can use ^ and
$ to specify an exact match at either end:

  • ^fizz will match fizzbazbuzz but not buzzfizzbaz
  • buzz$ will match fizzbazbuzz but not bazbuzzfizz

Specify a command to be run on the open file by appending a ":<CMD>" to the end
of the search query.

  • iz*buz:45 will open a file fizzbazbuzz and jump to line 45
  • iz*buz:diffthis will open a file fizzbazbuzz and add the file to the diff windows

Niffler has several different modes:

CommandDescription
NifflerFuzzy file search
NifflerMRUFuzzy file search on MRU cache
NifflerBufferFuzzy file search on buffer list
NifflerTagsFuzzy tag search on ctags list
NifflerTselectFuzzy tag search on matching tags
NifflerTjumpFuzzy tag search on matching tags, jump directly if only one match

The Niffler command takes any number of optional arguments and has the following structure:

Niffler [-vcs] [DIRECTORY]

  • -vcs: search from git root directory of current file
  • Directory to search from

Ctags Filtering

  • The NifflerTags command can optionally take a % as argument to only search
  1. tags in the current file.
  • The NifflerTselect command can be used to replace the built-in :tselect
  1. and filter a list of matching tags.

    • nnoremap <silent> g] :NifflerTselect<CR>
  • The NifflerTjump command can similarly be used to replace the built-in
    :tjump command. The command will jump directly to a tag if there is only

one match and otherwise will present a list of matching tags to filter

- `nnoremap <silent> g<C-]> :NifflerTjump<CR>`

Key Mappings

KeyAction
<C-K>, <C-P>, <Up>Move up one line in the candidate list
<C-J>, <C-N>, <Down>Move down one line in the candidate list
<C-A>Scroll to the beginning of the line
<C-E>Scroll to the end of the line
<C-R>Insert the contents of a register
<C-X>, <Left>Mark multiple selections for opening
<CR>, <Right>Open selection in current window
<C-S>Open selection in new horizontal split
<C-V>Open selection in new vertical split
<C-T>Open selection in new tab window
<Esc>, <C-[>, <C-C>Quit Niffler

Configuration

  • niffler#custom()

    • Create customized lists of candidates to filter through
  • g:niffler_user_command

    • Custom file indexing command, use %s in place of the target directory
    • i.e. let g:niffler_user_command = 'ag %s -g ""'
  • g:niffler_ignore_extensions

    • List of file extensions to exclude from Niffler results
    • Ignored when g:niffler_user_command is non-empty
  • g:niffler_ignore_dirs

    • List of directories to exclude from Niffler results
    • Helpful for large directories that could slow Niffler down
    • Ignored when g:niffler_user_command is non-empty
  • g:niffler_prompt

    • Prompt string for input
    • The placeholder %s is replaced with the prompt text (optional)
    • i.e. let g:niffler_prompt = '%s $ '
  • g:niffler_marked_indicator

    • Indicator which is used to mark selected entries
    • i.e. let g:niffler_marked_indicator = 'x '

Requirements

Niffler currently requires the grep, cut, and sed utilities for full

  1. Niffler is not tested on Windows and its current level of support is
    unknown.

Installation

  • [Pathogen][]

    • cd ~/.vim/bundle && git clone https://github.com/pgdouyon/vim-niffler.git
  • [Vundle][]

    • Plugin 'pgdouyon/vim-niffler'
  • [NeoBundle][]

    • NeoBundle 'pgdouyon/vim-niffler'
  • [Vim-Plug][]

    • Plug 'pgdouyon/vim-niffler'
  • Manual Install

    • Copy all the files into the appropriate directory under ~/.vim on *nix or
      $HOME/_vimfiles on Windows

License

Copyright (c) 2015 Pierre-Guy Douyon. Distributed under the MIT License.

添加新评论