replace.vim


Ⅰ. 插件描述

Replace operator for Vim

Ⅱ. 基本信息

创建日期:  2015-08-28
使用用户:  3
Github星:  13
插件作者:  Rom Grk

Ⅲ. 安装方法

使用Vundle管理器安装

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

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

使用NeoBundle管理器安装

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

使用VimPlug管理器安装

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

使用Pathogen管理器安装

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

Ⅳ. 文档说明

# Replace & Exchange Operator

Provides a replace and an exchange operator for vim.
The operation replaces the text object or motion with the content of the specified register.

ReplaceOperator use-case:
You need to replace some text with the content of a register (most likely the
default), while keeping the register content as is.

ExchangeOperator use-case:
You need to exchange some content with the content of the register.

ReplaceOperator example sequence: (cursor at |, <Plug>ReplaceOperator mapped to R)

This is a |sentence (with some brackets in it) over.

ye yank end
f( find (
Ri( replace inside (

This is a sentence (|sentence) over.

The replaced text is sent to the blank register by default.
This is configurable. (see below or doc)

ExchangeOperator example sequence: (cursor at |, <Plug>ExchangeOperator mapped to X)

let value = getPosition(|value, other)

ye yank end
W move W
Xe eXchange end

let value = getPosition(value, value|)

yiw yank inside word
Bb move back to value
Xe eXchange end

let value = getPosition(other|, value)

Usage

No default mappings are provided

nmap R <Plug>ReplaceOperator
vmap R <Plug>ReplaceOperator
" Alternative: s for 'substitute'
nmap s <Plug>ReplaceOperator
vmap s <Plug>ReplaceOperator

nmap X <Plug>ExchangeOperator

Configuration

let g:replace_register = '_' " Default: sends Replaced content to black hole register

The deleted text is placed in register g:replace_register.
Set it to '|' to exchange the value of the register and the selected text.
(In which case, ReplaceOperator will act exactly as ExchangeOperator)

License

Same as JSON license

添加新评论