Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kurkale6ka/vim-swap
Easy swapping of text in Vim
https://github.com/kurkale6ka/vim-swap
vim vim-plugin
Last synced: about 2 months ago
JSON representation
Easy swapping of text in Vim
- Host: GitHub
- URL: https://github.com/kurkale6ka/vim-swap
- Owner: kurkale6ka
- License: gpl-3.0
- Created: 2011-04-04T14:16:42.000Z (almost 14 years ago)
- Default Branch: master
- Last Pushed: 2020-04-06T09:40:53.000Z (almost 5 years ago)
- Last Synced: 2024-08-07T18:46:13.007Z (5 months ago)
- Topics: vim, vim-plugin
- Language: Vim script
- Homepage:
- Size: 27.3 KB
- Stars: 18
- Watchers: 2
- Forks: 6
- Open Issues: 1
-
Metadata Files:
- Readme: README.markdown
- License: LICENSE
Awesome Lists containing this project
README
Swapping of text in Vim
=======================A plugin which makes swapping of text in Vim easier
1. Visual mode
**1.1 `\x`**
First select some text (`[]` represents the highlighted area). Then press `\x`
[a == 123] [ a == 123 ] [a==123]
| | |
V V V
123 == a 123 == a 123==a_Note:_ Your selection can be loose and include white spaces at both ends.
**1.2 `\cx`**
By default the plugin acts on comparison operators
You are however allowed to specify any pivot for the swapping.First select some text. Then press `\cx`
You will be asked to give a pattern (`%` used here)Just testing % a percentage as a pivot
|
V
a percentage as a pivot % Just testing**1.3 Multiple lines**
You can also use `V`, `v` or `^v` to select several lines (`v` used), then press `\x`
a == [123
user !~ unknown
0]!=#1
|
V
123 == a
unknown !~ user
1!=#02. Normal mode
Swap with WORD on the right `\x`
`#` indicates the cursor position in the examples below.
#
zero one a_longer_word three
|
V
zero a_longer_word one threeSwap with WORD on the left `\X`
zero one two three
let's have some more fun
# |
V
zero one two let's
three have some more fun**2.1 Repeat**
This plugin integrates with Tim Pope's repeat plugin. It means that you can
use **. (dot)** to repeat any normal mode (for now) swap mapping you just used!For more information see: http://github.com/tpope/vim-repeat
3. Supported operators
_Comparison operators_
```
=== !== <> ==# !=# >#
>=# <# <=# =~# !~# ==?
!=? >? >=? <=? =~?
!~? == != >= =~ <=
!~ ~=
```_Logical operators_
`&& ||`_Assignment operators_
```
+= -= *= /= %= &=
|= ^= <<= >>=
```_Scope operators_
`::`_Pointer operators_
`->* -> .*`_Bitwise operators_
`<< >>`_Misc operators_
```
> < = + - *
/ % & | ^ .
? : , '= '< '>
!< !>
```**3.1 Custom operators**
You can define your own operators by putting a similar line in your _vimrc_:
let g:swap_custom_ops = ['first_operator', 'second_operator', ...]
4. Custom mappings
You have the possibility to define your own custom mappings in your _vimrc_:
vmap x SwapSwapOperands
vmap x SwapSwapPivotOperands
nmap x SwapSwapWithR_WORD
nmap X SwapSwapWithL_WORD_Note:_ You can replace `\x`, `\cx`, `\X` with whatever you like.