vim-esearch


Ⅰ. 插件描述

Perform search in files easily

Ⅱ. 基本信息

创建日期:  2015-07-20
使用用户:  10
Github星:  209
插件作者:  Eugen

Ⅲ. 安装方法

使用Vundle管理器安装

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

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

使用NeoBundle管理器安装

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

使用VimPlug管理器安装

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

使用Pathogen管理器安装

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

Ⅳ. 文档说明

# Vim ESearch

Build Status
Code Climate

NeoVim/Vim plugin performing project-wide async search and replace, similar to
SublimeText, Atom et al.

ESearch Demo gif


  1. Features
  2. Installation
  3. Usage
  4. Customization
    4.1. General Configs

4.2. Mappings
4.3. Colors


Features

  • Builtin support for superfast engines like
    ag (_The Silver Searcher_),

ack,
pt (_The Platinum Searcher_),
rg (_ripgrep_),
git-grep along with the
native *nix util grep.

  • Advanced pattern input prompt with fuzzy- and spell suggestion-driven completion.
  • Live updating of results as in Emacs, SublimeText and similar (requires Vim 8 / NeoVim job control or vimproc to be installed).
  • Special esearch window or quickfix list, habitual for all, can be used as an output target.
  • Search-and-Replace feature with the same syntax as builtin :substitute command (Example :1,5ESubstitute/from/to/gc).
  • Collaborates with nerdtree to provide search in a specific directory.

Installation

In your ~/.config/nvim/init.vim or ~/.vimrc :

Plugin 'eugen0329/vim-esearch'

NOTE
Plugin command (which comes with Vundle) can be replaced with
another command of the plugin manager you use (Plug,
NeoBundle etc.)

Usage

Type <leader>ff and insert a search pattern (usually <leader> is \).
Use s, v and t buttons to open file under the
cursor in split, vertical split and in tab accordingly. Use Shift
along with s, v and t buttons to open a file silently. Press Shift-r to reload
currrent results.

To switch between case-sensitive/insensitive, whole-word-match and regex/literal pattern in command
line use Ctrl-oCtrl-r, Ctrl-oCtrl-s or Ctrl-oCtrl-w (mnemonics is set Option: Regex,
case Sesnsitive, Word regex).

Customization

General Configs

Global ESearch configuration example:

let g:esearch = {
  \ 'adapter':          'ag',
  \ 'backend':          'vimproc',
  \ 'out':              'win',
  \ 'batch_size':       1000,
  \ 'use':              ['visual', 'hlsearch', 'last'],
  \ 'default_mappings': 1,
  \}
  • 'adapter'

    Adapter is a system-wide executable, which is used to dispatch your search

    1. Currently available adapters are 'ag', 'ack', 'pt', 'rg', 'git' and 'grep'.
  • 'backend'

    Backend is a strategy, which is used to collaborate with an adapter. Currently available:

async backends - 'nvim', 'vimproc', 'vim8', and vim builtin system() func call based backend
'system'

NOTE 'nvim' and 'vimproc' requires NeoVim and vimproc respectively.

  • 'out'

    Results output target: 'win' - ESearch window (see demo) or 'qflist' - quickfix window
  • 'batch_size'

    So not to hang your vim while updating results, ESearch uses batches. Thus,

'batch_size' refers to the number of result lines can be processed at one time

  • 'use'

    With this option you can specify the initial search request string, which will be

picked from a specific source. Order is relevant for priorities of this sources usage. To always start with an empty input - set this option to []. Sources are:

* `'visual'`<br>
  Selected text. Only available from the visual mode.
* `'hlsearch'`<br>
  Current search (with /) highlight
* `'last'`<br>
  Previously used ESearch pattern
* `'clipboard'`<br>
  Text yanked with <kbd>y</kbd>, deleted with <kbd>s</kbd>, <kbd>l</kbd> etc.<br>
* `'system_clipboard'`<br>
  Text you copied with <kbd>Ctrl-c</kbd> or cut with <kbd>Ctrl-x</kbd>.<br>
* `'system_selection_clipboard'`<br>
  Text selected with mouse or other similar method (only works on Linux).<br>
* `'word_under_cursor'`<br>
  A word under the cursor.<br>
  • 'default_mappings'

    Allows you to disable default mappings. If set to 0, no default mappings will

be added.

Mappings

In ~/.config/nvim/init.vim / ~/.vimrc:

Use the following functions to redefine default mappings (NOTE default
mapping are listed as an example here):

    " Start esearch prompt autofilled with one of g:esearch.use initial patterns
    call esearch#map('<leader>ff', 'esearch')
    " Start esearch autofilled with a word under the cursor
    call esearch#map('<leader>fw', 'esearch-word-under-cursor')

    call esearch#out#win#map('t',       'tab')
    call esearch#out#win#map('i',       'split')
    call esearch#out#win#map('s',       'vsplit')
    call esearch#out#win#map('<Enter>', 'open')
    call esearch#out#win#map('o',       'open')

    "    Open silently (keep focus on the results window)
    call esearch#out#win#map('T', 'tab-silent')
    call esearch#out#win#map('I', 'split-silent')
    call esearch#out#win#map('S', 'vsplit-silent')

    "    Move cursor with snapping
    call esearch#out#win#map('<C-n>', 'next')
    call esearch#out#win#map('<C-j>', 'next-file')
    call esearch#out#win#map('<C-p>', 'prev')
    call esearch#out#win#map('<C-k>', 'prev-file')

    call esearch#cmdline#map('<C-o><C-r>', 'toggle-regex')
    call esearch#cmdline#map('<C-o><C-s>', 'toggle-case')
    call esearch#cmdline#map('<C-o><C-w>', 'toggle-word')
    call esearch#cmdline#map('<C-o><C-h>', 'cmdline-help')

Colors

To redefine results match highlight use:

hi ESearchMatch ctermfg=black ctermbg=white guifg=#000000 guibg=#E6E6FA

Known issues

so as a result you have implicit regexp matching here and have to escape special
characters or switch to case sensitive mode.

添加新评论