All Projects → kurkale6ka → vim-swap

kurkale6ka / vim-swap

Licence: GPL-3.0 license
Easy swapping of text in Vim

Programming Languages

Vim Script
2826 projects

Projects that are alternatives of or similar to vim-swap

pfp-vim
A vim hex-editor plugin that uses 010 templates to parse binary data using pfp
Stars: ✭ 57 (+216.67%)
Mutual labels:  vim-plugin
vim-win
🖼️ A Vim plugin for managing windows.
Stars: ✭ 48 (+166.67%)
Mutual labels:  vim-plugin
42header.vim
Add and update the 42 comment header at the top of your files
Stars: ✭ 15 (-16.67%)
Mutual labels:  vim-plugin
spotdiff.vim
A range and area selectable diffthis to compare partially
Stars: ✭ 29 (+61.11%)
Mutual labels:  vim-plugin
vim-jsonc
⚠️Deprecated⚠️: Vim syntax highlighting plugin for JSON with C-style line (//) and block (/* */) comments.
Stars: ✭ 52 (+188.89%)
Mutual labels:  vim-plugin
vim-easydebugger
A VIM multi-language debugger plugin
Stars: ✭ 47 (+161.11%)
Mutual labels:  vim-plugin
hlyank.vim
Highlight yanked text in Vim
Stars: ✭ 14 (-22.22%)
Mutual labels:  vim-plugin
cosme.vim
Cosmetic color scheme for Vim
Stars: ✭ 63 (+250%)
Mutual labels:  vim-plugin
code runner.nvim
Neovim plugin.The best code runner you could have, it is like the one in vscode but with super powers, it manages projects like in intellij but without being slow
Stars: ✭ 234 (+1200%)
Mutual labels:  vim-plugin
swifty-vim
⌨️ A Vim plugin for Swift which provides file detection, syntax highlighting, support for compiling and running tests, and optional support for formatting and linting tools.
Stars: ✭ 18 (+0%)
Mutual labels:  vim-plugin
notoire
A vim plugin to take notes using the Zettelkasten method
Stars: ✭ 53 (+194.44%)
Mutual labels:  vim-plugin
dps-ghosttext.vim
GhostText plugin powered by denops.vim
Stars: ✭ 20 (+11.11%)
Mutual labels:  vim-plugin
vim-sage
Vim plugin for SageMath (Sage) mathematics software system
Stars: ✭ 17 (-5.56%)
Mutual labels:  vim-plugin
vim-lineletters
because letters are easier to touch type than numbers
Stars: ✭ 38 (+111.11%)
Mutual labels:  vim-plugin
vim-thematic
Alter Vim's appearance to suit your task & environ
Stars: ✭ 218 (+1111.11%)
Mutual labels:  vim-plugin
perl-support
Edit Perl scripts in Vim/gVim. Insert code snippets, run, check, and profile the code and look up help.
Stars: ✭ 23 (+27.78%)
Mutual labels:  vim-plugin
vim-textobj-sentence
Improving on Vim's native sentence text object and motion
Stars: ✭ 92 (+411.11%)
Mutual labels:  vim-plugin
vim-counterpoint
Cycle between file counterparts in vim or neovim.
Stars: ✭ 12 (-33.33%)
Mutual labels:  vim-plugin
CommentFrame.vim
Add Comments in Frames to the file you're editing, or Comments aligned on the Right side of a line. Customizable!
Stars: ✭ 42 (+133.33%)
Mutual labels:  vim-plugin
auto-pairs
Vim plugin, insert or delete brackets, parentheses, and quotes in pairs
Stars: ✭ 109 (+505.56%)
Mutual labels:  vim-plugin

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!=#0

2. 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 three

Swap 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 <leader>x         <plug>SwapSwapOperands
vmap <leader><leader>x <plug>SwapSwapPivotOperands
nmap <leader>x         <plug>SwapSwapWithR_WORD
nmap <leader>X         <plug>SwapSwapWithL_WORD

Note: You can replace \x, \cx, \X with whatever you like.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].