matze / vim-move

Plugin to move lines and selections up and down
http://www.vim.org/scripts/script.php?script_id=4687
MIT License
1.2k stars 56 forks source link

[Feature Request] Add visual selection left/right movement #25

Closed willdavidow closed 6 years ago

willdavidow commented 6 years ago

I'm wondering if it's possible to add functionality that allows movement of a visual selection (non-full-line) left and right within a line, shifting the characters outside the selection left and right as the selection is moved left or right within the line...

Consider adding the following (new/configurable) key bindings:

<A-h>   Move visual selection left
<A-l>   Move visual selection right

For ex, the following line of html:

<div id="example" class=""></div>

I'd like to move the id attribute value to the class value (for whatever reason), so I visually select example:

<div id="example" class=""></div>

and I would like to shift example over to the right inside of class, so I press 9<A-l> to move class over 9 columns to the right:

<div id="" class="example"></div>

or move it over by pressing <A-l> repeatedly until I've shifted it over column by column:

<div id="example" class=""></div> <div id=""exampleclass=""></div> <div id="" cexamplelass=""></div> <div id="" clexampleass=""></div> <div id="" claexampless=""></div> <div id="" clasexamples=""></div> <div id="" classexample=""></div> <div id="" class=example""></div> <div id="" class="example"></div>

matze commented 6 years ago

Hmm, sounds intriguiging. I will think about it but honestly I think it's just quicker to di"f"p to get the same result.

willdavidow commented 6 years ago

di"f"p definitely works/is faster for my specific example... but sometimes it's nice to do things visually, and is the reason I use this plugin vs. moving a line and/or block up/down three lines using d3kp/d3jp

Thanks for considering the addition. If I can find some time to learn how to add to the plugin, I may submit a PR... otherwise I'll keep my fingers crossed that you're interested in and able to do it .

saulaxel commented 6 years ago

I already did a PR with this functionality

matze commented 6 years ago

Merged @saulaxel PR, so this can be closed.