greplace.vim


Ⅰ. 插件描述

Global search and replace for VI

Ⅱ. 基本信息

创建日期:  2010-10-08
更新日期:  6年以前
使用用户:  452
Github星:  109
插件作者:  Yan Pritzker

Ⅲ. 安装方法

使用Vundle管理器安装

在你的.vimrc下添加:
Plugin 'skwp/greplace-vim-sad-beautiful-tragic'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall

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

使用NeoBundle管理器安装

在你的.vimrc下添加:
NeoBundle 'skwp/greplace-vim-sad-beautiful-tragic'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall

使用VimPlug管理器安装

在你的.vimrc下添加:
Plug 'skwp/greplace-vim-sad-beautiful-tragic'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall

使用Pathogen管理器安装

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

Ⅳ. 文档说明

VIM Plugin for doing a search and replace across many files.

About this plugin

Original plugin by Yegappan Lakshmanan
http://www.vim.org/scripts/script.php?script_id=1813

Modifications by Yan Pritzker:

  • Always grep recursive
  • Silence the search so you don't get a gigantic scroll list

Usage

  1. Use :Gsearch <search> to get a buffer window of your search results
  2. then you can make the replacements inside the buffer window using traditional tools (%s/foo/bar/)
  3. Invoke :Greplace to make your changes across all files. It will ask you interatively y/n/a - you can hit 'a' to do all.
  4. Save changes to all files with :wall (write all)

Customization

To customize command used for :Gsearch you can update both the command and
the default options.

_Note_: updating grepprg will have consequences on other
commands that rely on grep vim command

  • git grep

    set grepprg=git grep

    let g:grep_cmd_opts = '--line-number'

  • ag

    set grepprg=ag

    let g:grep_cmd_opts = '--line-numbers --noheading'

  • ack

    set grepprg=ack

    let g:grep_cmd_opts = '--noheading'

添加新评论