Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/romgrk/replace.vim
Replace operator for Vim
https://github.com/romgrk/replace.vim
exchange-operator vim
Last synced: about 1 month ago
JSON representation
Replace operator for Vim
- Host: GitHub
- URL: https://github.com/romgrk/replace.vim
- Owner: romgrk
- Created: 2015-08-28T18:06:28.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2018-03-01T19:03:29.000Z (over 6 years ago)
- Last Synced: 2024-08-08T17:16:37.726Z (3 months ago)
- Topics: exchange-operator, vim
- Language: Vim script
- Size: 5.86 KB
- Stars: 19
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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 `|`, `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 `|`, `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*
```vim
nmap R ReplaceOperator
vmap R ReplaceOperator
" Alternative: s for 'substitute'
nmap s ReplaceOperator
vmap s ReplaceOperatornmap X ExchangeOperator
```## Configuration
```vim
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