Hi, I found that I'm using my own
duplicate_lines() alias '
dl' macro quite a lot. So I though I should post it here.
Maybe someone else also thinks that the stock
duplicate_line() is too limited
I even bound it to a key combination (SHIFT-ALT-INS in my case)...
Description:
If nothing is selected it behaves like duplicate_line() and dups the current line.
If something
is selected (any selection can be used: CHAR/BLOCK/LINE) comprising one or more lines these lines are duplicated.
You can use top-down or bottom-up selections. The affected lines are always copied below the initial selection.
The resulting copy is still (LINE) selected to repeat the command a number of times.
The selection is cleared on next cursor move. Intentionally NO clipboard is created or used.
Unfortunately I'm not 100% sure if it works with all selection configurations.
_command void duplicate_lines,dl () name_info(','VSARG2_MARK|VSARG2_TEXT_BOX|VSARG2_REQUIRES_EDITORCTL)
{
boolean single_line = !select_active ();
if ( single_line ) select_line();
else _select_type("",'T','LINE');
int endsel = _end_select_compare();
if ( endsel < 0 ) // handle bottom up selection
{
deselect();
select_line();
// - -N = +N
p_line -= endsel;
}
_copy_to_cursor();
if ( single_line ) deselect();
// optionally go to the beginning of the dup'd lines
down();
// first_non_blank();
}
Have fun,
HS2