summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--editors/vi.c77
1 files changed, 39 insertions, 38 deletions
diff --git a/editors/vi.c b/editors/vi.c
index a22a6a1..633d42a 100644
--- a/editors/vi.c
+++ b/editors/vi.c
@@ -3015,17 +3015,17 @@ static void do_cmd(int c)
case KEYCODE_LEFT: // cursor key Left
case 8: // ctrl-H- move left (This may be ERASE char)
case 0x7f: // DEL- move left (This may be ERASE char)
- if (cmdcnt-- > 1) {
+ if (--cmdcnt > 0) {
do_cmd(c);
- } // repeat cnt
+ }
dot_left();
break;
case 10: // Newline ^J
case 'j': // j- goto next line, same col
case KEYCODE_DOWN: // cursor key Down
- if (cmdcnt-- > 1) {
+ if (--cmdcnt > 0) {
do_cmd(c);
- } // repeat cnt
+ }
dot_next(); // go to next B-o-l
dot = move_to_col(dot, ccol + offset); // try stay in same col
break;
@@ -3040,9 +3040,9 @@ static void do_cmd(int c)
break;
case 13: // Carriage Return ^M
case '+': // +- goto next line
- if (cmdcnt-- > 1) {
+ if (--cmdcnt > 0) {
do_cmd(c);
- } // repeat cnt
+ }
dot_next();
dot_skip_over_ws();
break;
@@ -3062,9 +3062,9 @@ static void do_cmd(int c)
case ' ': // move right
case 'l': // move right
case KEYCODE_RIGHT: // Cursor Key Right
- if (cmdcnt-- > 1) {
+ if (--cmdcnt > 0) {
do_cmd(c);
- } // repeat cnt
+ }
dot_right();
break;
#if ENABLE_FEATURE_VI_YANKMARK
@@ -3147,9 +3147,10 @@ static void do_cmd(int c)
#endif /* FEATURE_VI_YANKMARK */
case '$': // $- goto end of line
case KEYCODE_END: // Cursor Key End
- if (cmdcnt-- > 1) {
+ if (--cmdcnt > 0) {
+ dot_next();
do_cmd(c);
- } // repeat cnt
+ }
dot = end_line(dot);
break;
case '%': // %- find matching char of pair () [] {}
@@ -3175,9 +3176,9 @@ static void do_cmd(int c)
//
//**** fall through to ... ';'
case ';': // ;- look at rest of line for last forward char
- if (cmdcnt-- > 1) {
+ if (--cmdcnt > 0) {
do_cmd(';');
- } // repeat cnt
+ }
if (last_forward_char == 0)
break;
q = dot + 1;
@@ -3188,9 +3189,9 @@ static void do_cmd(int c)
dot = q;
break;
case ',': // repeat latest 'f' in opposite direction
- if (cmdcnt-- > 1) {
+ if (--cmdcnt > 0) {
do_cmd(',');
- } // repeat cnt
+ }
if (last_forward_char == 0)
break;
q = dot - 1;
@@ -3202,9 +3203,9 @@ static void do_cmd(int c)
break;
case '-': // -- goto prev line
- if (cmdcnt-- > 1) {
+ if (--cmdcnt > 0) {
do_cmd(c);
- } // repeat cnt
+ }
dot_prev();
dot_skip_over_ws();
break;
@@ -3238,9 +3239,9 @@ static void do_cmd(int c)
// user changed mind and erased the "/"- do nothing
break;
case 'N': // N- backward search for last pattern
- if (cmdcnt-- > 1) {
+ if (--cmdcnt > 0) {
do_cmd(c);
- } // repeat cnt
+ }
dir = BACK; // assume BACKWARD search
p = dot - 1;
if (last_search_pattern[0] == '?') {
@@ -3252,9 +3253,9 @@ static void do_cmd(int c)
case 'n': // n- repeat search for last pattern
// search rest of text[] starting at next char
// if search fails return orignal "p" not the "p+1" address
- if (cmdcnt-- > 1) {
+ if (--cmdcnt > 0) {
do_cmd(c);
- } // repeat cnt
+ }
dc3:
dir = FORWARD; // assume FORWARD search
p = dot + 1;
@@ -3405,9 +3406,9 @@ static void do_cmd(int c)
case 'B': // B- back a blank-delimited Word
case 'E': // E- end of a blank-delimited word
case 'W': // W- forward a blank-delimited word
- if (cmdcnt-- > 1) {
+ if (--cmdcnt > 0) {
do_cmd(c);
- } // repeat cnt
+ }
dir = FORWARD;
if (c == 'B')
dir = BACK;
@@ -3455,9 +3456,9 @@ static void do_cmd(int c)
if (cmdcnt > (rows - 1)) {
cmdcnt = (rows - 1);
}
- if (cmdcnt-- > 1) {
+ if (--cmdcnt > 0) {
do_cmd('+');
- } // repeat cnt
+ }
dot_skip_over_ws();
break;
case 'I': // I- insert before first non-blank
@@ -3470,9 +3471,9 @@ static void do_cmd(int c)
cmd_mode = 1; // start insrting
break;
case 'J': // J- join current and next lines together
- if (cmdcnt-- > 2) {
+ if (--cmdcnt > 1) {
do_cmd(c);
- } // repeat cnt
+ }
dot_end(); // move to NL
if (dot < end - 1) { // make sure not last char in text[]
*dot++ = ' '; // replace NL with space
@@ -3488,9 +3489,9 @@ static void do_cmd(int c)
if (cmdcnt > (rows - 1)) {
cmdcnt = (rows - 1);
}
- if (cmdcnt-- > 1) {
+ if (--cmdcnt > 0) {
do_cmd('-');
- } // repeat cnt
+ }
dot_begin();
dot_skip_over_ws();
break;
@@ -3524,9 +3525,9 @@ static void do_cmd(int c)
case 'X': // X- delete char before dot
case 'x': // x- delete the current char
case 's': // s- substitute the current char
- if (cmdcnt-- > 1) {
+ if (--cmdcnt > 0) {
do_cmd(c);
- } // repeat cnt
+ }
dir = 0;
if (c == 'X')
dir = -1;
@@ -3568,9 +3569,9 @@ static void do_cmd(int c)
break;
case 'b': // b- back a word
case 'e': // e- end of word
- if (cmdcnt-- > 1) {
+ if (--cmdcnt > 0) {
do_cmd(c);
- } // repeat cnt
+ }
dir = FORWARD;
if (c == 'b')
dir = BACK;
@@ -3669,9 +3670,9 @@ static void do_cmd(int c)
}
case 'k': // k- goto prev line, same col
case KEYCODE_UP: // cursor key Up
- if (cmdcnt-- > 1) {
+ if (--cmdcnt > 0) {
do_cmd(c);
- } // repeat cnt
+ }
dot_prev();
dot = move_to_col(dot, ccol + offset); // try stay in same col
break;
@@ -3691,9 +3692,9 @@ static void do_cmd(int c)
last_forward_char = 0;
break;
case 'w': // w- forward a word
- if (cmdcnt-- > 1) {
+ if (--cmdcnt > 0) {
do_cmd(c);
- } // repeat cnt
+ }
if (isalnum(*dot) || *dot == '_') { // we are on ALNUM
dot = skip_thing(dot, 1, FORWARD, S_END_ALNUM);
} else if (ispunct(*dot)) { // we are on PUNCT
@@ -3719,9 +3720,9 @@ static void do_cmd(int c)
dot = move_to_col(dot, cmdcnt - 1); // try to move to column
break;
case '~': // ~- flip the case of letters a-z -> A-Z
- if (cmdcnt-- > 1) {
+ if (--cmdcnt > 0) {
do_cmd(c);
- } // repeat cnt
+ }
if (islower(*dot)) {
*dot = toupper(*dot);
file_modified++;