// Using the cursor-up or cursor-down keys,
// display on the message line the total number
// of lines the cursor has moved.
// Assign a key combination to the line_counter
// command. Press the key combo to start the counter.
// It initializes with a value of 0. Press ESC to stop.
//
// Move your cursor up or down to reach your target.
// The target is typically a certain number of lines you
// want to traverse, or some specific text you want to
// reach. With each cursor-up/down keystroke the displayed
// count will decrement or increment by 1. Moving the
// cursor up will decrement the number of lines;
// moving the cursor down increments the line count.
// Change this if you want.
//
// This macro can actually be valuable once in a while.
// But I must plead ignorant for now; I've forgotten what I
// use it for!
_command line_counter() name_info(','VSARG2_REQUIRES_EDITORCTL|VSARG2_READ_ONLY)
{
lines=0;
message('Number of lines traversed='lines)
for (;;) {
key = get_event();
keyname=event2name(key);
if (keyname=='DOWN') {
cursor_down();
++lines;
}
if (keyname=='UP') {
cursor_up();
--lines;
}
message('Linecount='lines)
if (keyname=='ESC') {
message('Linectr cancelled')
break;
}
}
}
0 comments:
Post a Comment