Transpose Lines

Friday, September 26, 2008

Another simple macro. If you're sometimes lazy like me, you might find this command saves some time and saves some time thinking.

Assign a key combination to the macro. Whenever you want to swap a line of text with the line above it (or vice versa), simply place the cursor on the bottom line of the two lines. Press your key combo. The line the cursor is on is moved up one line, leaving the line that was above it, below it.

// Exchange current line with the line above
_command void transpose_lines() name_info(','VSARG2_REQUIRES_EDITORCTL)
{
if ( _on_line0() ) {
return;
}
markid=_alloc_selection();
if (markid<0) {
// This should not happen.
return;
}
_select_line(markid);
up();
special_case=0;
if (_on_line0()) {
status=down(2);
if (status) return;
special_case=1;
} else {
up();
}
_move_to_cursor(markid);
if (special_case) {
down;
} else {
down(2);
}
_free_selection(markid);
}

0 comments:

Post a Comment

GlossyBlue Blogger by Black Quanta. Theme & Icons by N.Design Studio
Entries RSS Comments RSS