Ⅰ. 插件描述
Search context in Vim in a sidebar using `ag` outputⅡ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin 'ddrscott/vim-side-search'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle 'ddrscott/vim-side-search'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug 'ddrscott/vim-side-search'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/ddrscott/vim-side-search
Ⅳ. 文档说明
## Overview
The quickfix window is great, but it would be nice to get some context around
our searches. This plugin adds ag output to a side buffer with quick
navigation mappings using comfortable Vim conventions.

Features
- step through
agoutput instead ofquickfixoutput - syntax highlighting of
agoutput - mappable to search current word under cursor
- configurable
g:side_search_prgsimilar togrepprg - vertical or horizontal split output via
g:side_search_splitter
Buffer Mappings
n/N - Cursor to next/prev
<C-n>/<C-p> - Open next/prev
<CR>|<DblClick> - Open at cursor
<C-w><CR> - Open and jump to window
qf - :grep! to QuickfixPrerequisites
We rely on The Silver Searcher
to perform our file/text searches for us. Theoretically any program which has
the same output could also work, but that we only test using ag output.
To install ag command on OSX:
brew install the_silver_searcherFor refer to
The Silver Searcher
for more instructions.
Global Configuration
" How should we execute the search?
" --heading and --stats are required!
let g:side_search_prg = 'ag --word-regexp'
\. " --ignore='*.js.map'"
\. " --heading --stats -B 1 -A 4"
" Can use `vnew` or `new`
let g:side_search_splitter = 'vnew'
" I like 40% splits, change it if you don't
let g:side_search_split_pct = 0.4Suggested Mapping
" SideSearch current word and return to original window
nnoremap <Leader>ss :SideSearch <C-r><C-w><CR> | wincmd p
" Create an shorter `SS` command
command! -complete=file -nargs=+ SS execute 'SideSearch <args>'
" or command abbreviation
cabbrev SS SideSearchFAQ
How to search for multi-word terms?
Surround terms with double quotes
:SideSearch "cats and dogs"How to pass extra args to
ag?
Just do it :)
:SideSearch --js MyAwesomeComponent