ag


Ⅰ. 插件描述

vim plugin to search using the silver searcher (ag)

Ⅱ. 基本信息

创建日期:  2012-10-21
使用用户:  25
Github星:  44
插件作者:  Eric Van Dewoestine

Ⅲ. 安装方法

使用Vundle管理器安装

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

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

使用NeoBundle管理器安装

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

使用VimPlug管理器安装

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

使用Pathogen管理器安装

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

Ⅳ. 文档说明

.. Copyright (c) 2012 - 2014, Eric Van Dewoestine
All rights reserved.

Redistribution and use of this software in source and binary forms, with
or without modification, are permitted provided that the following
conditions are met:

  • Redistributions of source code must retain the above
    copyright notice, this list of conditions and the
    following disclaimer.
  • Redistributions in binary form must reproduce the above
    copyright notice, this list of conditions and the
    following disclaimer in the documentation and/or other
    materials provided with the distribution.
  • Neither the name of Eric Van Dewoestine nor the names of its
    contributors may be used to endorse or promote products derived from
    this software without specific prior written permission of
    Eric Van Dewoestine.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

.. _overview:

========

Overview

ag.vim is a plugin for vim which allows you to search over files using the
silver searcher (ag)_.

=====

Usage

::

:Ag [options] pattern [directory]

The :Ag command provides several features to make running ag easier:

  • :Ag supports command completion of:

    • patterns from your search history: You can hit <tab> when starting to
      run :Ag and you can choose from a list of 10 of your most recent

      1. A common use case while editing code could be to hit * on a
      2. name to search for occurrences in the current file, then to run

    :Ag <tab> to search for the function across all files.

    • ag options: If you type - and then hit <tab>, you can scroll
      through all the ag.vim supported ag options.
    • file/directory name to search in: Once you've supplied a search
      pattern, the next argument to :Ag is an optional directory or file to

    search in and you can make use of <tab> completion to choose that file or
    directory.

Note: I highly recommend turning on vim's wildmenu support to get the most
out of vim's command completion:

::

set wildmenu
set wildmode=longest:full,full
  • Some vim based regex atoms in the supplied pattern will be converted to their
    PCRE equivalent so that you can do something like hit * on a word in vim,

then run :Ag <tab> or :Ag <c-r>/ to search for that word with ag
without having to convert the pattern yourself:

    • Word boundaries: \<Word\> will be converted to \bWord\b
    • Non-greedy matches: foo.\{-}bar will be converted to foo.*?bar
    • The directory argument supplied to :Ag supports simple glob patterns. To
      simplify filtering of your search by file extension, you can pass a glob

    pattern to :Ag and it will convert it to a file search regex for ag. For
    example, to limit your search to only python files starting in some directory,
    you could run:

    ::

    :Ag FooBar foo/**/*.py
    

    This will be converted to the equivalent of running:

    ::

    :Ag -G foo/.*/[^/]*\.py$ FooBar
    

    =============

    Configuration

    • g:AgSmartCase (default: 0) - When set to a non-0 value, :Ag will run
      ag with the --smart-case option.

    ======

    Extras

    ag.vim also registers itself as a backend for eclim's :LocateFile

    1. You can even set ag as the default for non-eclim projects by
    2. the following to your vimrc:

    ::

    let g:EclimLocateFileNonProjectScope = 'ag'

    Note: requires eclim 2.2.5 or greater (or 1.7.13 or greater for Indigo users).

    .. _silver searcher (ag): https://github.com/ggreer/the_silver_searcher
    .. _eclim's: http://eclim.org
    .. _:LocateFile: http://eclim.org/vim/core/locate.html

    添加新评论