LineJuggler : Duplicate and move around lines.
| script karma |
Rating 11/5,
Downloaded by 166
|
Comments, bugs, improvements
|
Vim wiki
|
| created by |
| Ingo Karkat |
| |
| script type |
| utility |
| |
| description |
DESCRIPTION
This plugin offers mappings to quickly duplicate and move lines to above /
below the current line. A [count] either specifies the number of lines, or the
relative visible target line, therefore it's especially easy to clone lines
when 'relativenumber' is set.
The mappings can save you several keystrokes over an explicit dd/
yy[{motion}, ...]p sequence in cases where the other lines are nearby and
visible in the current window.
Oftentimes, duplication in source code is a code smell. Please use this plugin
responsibly ;-)
SEE ALSO
- The swap functionality of the plugin's [E / ]E mappings are also
available as an Ex :Swap command, provided by the companion
LineJugglerCommands.vim plugin (vimscript #4465).
RELATED WORKS
- Idea, design and implementation of the [<Space> and [e mappings are based on
Tim Pope's unimpaired.vim plugin (vimscript #1590). In addition, unimpaired
provides other, unrelated functionality (all via [... / ]... mappings), but
doesn't offer customization of the mappings.
USAGE
[<Space> Add [count] blank lines above the current line / above
the start of the selection.
]<Space> Add [count] blank lines below the current line / below
the end of the selection.
[e Move the current line / selection [count] lines above.
]e Move the current line / selection [count] lines below.
[E Exchange the current line with the line / closed fold
[count] lines above.
Exchange the current closed fold with the same amount
of visible lines as are in the fold, [count] lines
above.
{Visual}[E Exchange the selection with the same amount of visible
lines located [count] lines above.
]E Exchange the current line with the line / closed fold
[count] lines below.
Exchange the current closed fold with the same amount
of visible lines as are in the fold, [count] lines
below.
{Visual}]E Exchange the selection with the same amount of visible
lines located [count] lines below.
[d Duplicate the current line / selection directly
above / across [count] lines above the current line /
above the start of the selection.
]d Duplicate the current line / selection directly
below / across [count] lines below the current line /
below the end of the selection.
[D Duplicate the current / [count] lines to above the
current line.
{Visual}[D Duplicate the selection [count] times above the
selection.
]D Duplicate the current / [count] lines to below that
range.
{Visual}]D Duplicate the selection [count] times below the
selection.
[f Fetch the line [count] visible lines below the current
line and duplicate it below the current line.
]f Fetch the line [count] visible lines above the current
line and duplicate it below the current line.
{Visual}[f Fetch the same number of visible lines starting from
the line [count] lines below the current line and
duplicate them above the start of the selection.
{Visual}]f Fetch the same number of visible lines starting from
the line [count] lines above the current line and
duplicate them below the end of the selection.
[r Fetch the line [count] visible lines below the current
line and replace the current line with it.
]r Fetch the line [count] visible lines above the current
line and replace the current line with it.
{Visual}[r Replace the selection with the same number of visible
lines fetched starting from the line [count] lines
below the current line.
{Visual}]r Replace the selection with the same number of visible
lines fetched starting from the line [count] lines
above the current line.
When the cursor is on a closed fold or the selection
contains a closed fold, the entire set of folded lines
is used. All mappings treat closed folds as a fixed
entity, so they will never move / duplicate into a
closed fold, always over it.
A [count] specifies visible lines, closed folds are
counted as one line, so you can use the
'relativenumber' column to easily reach a target.
(Except for v_[d and v_]d when at the opposite
side of the selection.) |
| |
| install details |
INSTALLATION
This script is packaged as a vimball. If you have the "gunzip" decompressor
in your PATH, simply edit the *.vmb.gz package in Vim; otherwise, decompress
the archive first, e.g. using WinZip. Inside Vim, install by sourcing the
vimball or via the :UseVimball command.
vim LineJuggler*.vmb.gz
:so %
To uninstall, use the :RmVimball command.
DEPENDENCIES
- Requires Vim 7.0 or higher.
- repeat.vim (vimscript #2136) plugin (optional)
- visualrepeat.vim (vimscript #3848) plugin (optional)
CONFIGURATION
If you want to use different mappings, map your keys to the
<Plug>(LineJuggler...) mapping targets _before_ sourcing the script (e.g. in
your vimrc):
nmap <C-Up> <Plug>(LineJugglerBlankUp)
nmap <C-Down> <Plug>(LineJugglerBlankDown)
vmap <C-Up> <Plug>(LineJugglerBlankUp)
vmap <C-Down> <Plug>(LineJugglerBlankDown) |
| |
script versions (upload new version)
Click on the package to download.
| LineJuggler-1.22.vmb.gz |
1.22 |
2013-03-08 |
7.0 |
Ingo Karkat |
- Expose s:DoSwap() as LineJuggler#SwapRanges() for use with the companion LineJugglerCommands.vim plugin. |
| LineJuggler-1.21.vmb.gz |
1.21 |
2012-09-03 |
7.0 |
Ingo Karkat |
- Avoid clobbering the expression register. |
| LineJuggler.vba.gz |
1.20 |
2012-07-27 |
7.0 |
Ingo Karkat |
- CHG: [d / ]d duplication without [count] still duplicates to the directly adjacent line, but with [count] now across [count] lines, which aligns with the 'relativenumber' hint.
- FIX: Correct clipping at the end for the ]E mapping.
- FIX: Make sure that v_[E / v_]E never swap with a single folded target line; this special behavior is reserved for the single-line normal mode swap.
- CHG: For visual selections in v_[E, v_[f, v_[r, also use the amount of visible lines, not the number of lines contained in the selection. This makes it more consistent with the overall plugin behavior and is hopefully also more useful.
- The workaround in s:PutWrapper() is not necessary after Vim version 7.3.272; add conditional. |
| LineJuggler.vba.gz |
1.10 |
2012-07-23 |
7.0 |
Ingo Karkat |
CHG: Split [f and {Visual}[f behaviors into two families of mappings:
a) [f to fetch below current line and {Visual}[f to fetch selected number of lines above/below selection
b) [r to fetch and replace current line / selection. |
| LineJuggler.vba.gz |
1.00 |
2012-07-20 |
7.0 |
Ingo Karkat |
Initial upload |
ip used for rating: 184.72.184.104
|