+ case CNTRL('W'):
+ case VICMD(CNTRL('W')):
+ /* Control-W -- Remove the last word */
+ while (cursor > 0 && isspace(command[cursor-1]))
+ input_backspace();
+ while (cursor > 0 &&!isspace(command[cursor-1]))
+ input_backspace();
+ break;
+#if CONFIG_FEATURE_COMMAND_EDITING_VI
+ case VICMD('i'):
+ vi_cmdmode = 0;
+ break;
+ case VICMD('I'):
+ input_backward(cursor);
+ vi_cmdmode = 0;
+ break;
+ case VICMD('a'):
+ input_forward();
+ vi_cmdmode = 0;
+ break;
+ case VICMD('A'):
+ input_end();
+ vi_cmdmode = 0;
+ break;
+ case VICMD('x'):
+ input_delete(1);
+ break;
+ case VICMD('X'):
+ if (cursor > 0) {
+ input_backward(1);
+ input_delete(1);
+ }
+ break;
+ case VICMD('W'):
+ vi_Word_motion(command, 1);
+ break;
+ case VICMD('w'):
+ vi_word_motion(command, 1);
+ break;
+ case VICMD('E'):
+ vi_End_motion(command);
+ break;
+ case VICMD('e'):
+ vi_end_motion(command);
+ break;
+ case VICMD('B'):
+ vi_Back_motion(command);
+ break;
+ case VICMD('b'):
+ vi_back_motion(command);
+ break;
+ case VICMD('C'):
+ vi_cmdmode = 0;
+ /* fall through */
+ case VICMD('D'):
+ goto clear_to_eol;
+
+ case VICMD('c'):
+ vi_cmdmode = 0;
+ /* fall through */
+ case VICMD('d'):
+ {
+ int nc, sc;
+ sc = cursor;
+ prevc = ic;
+ if (safe_read(0, &c, 1) < 1)
+ goto prepare_to_die;
+ if (c == (prevc & 0xff)) {
+ /* "cc", "dd" */
+ input_backward(cursor);
+ goto clear_to_eol;
+ break;
+ }
+ switch(c) {
+ case 'w':
+ case 'W':
+ case 'e':
+ case 'E':
+ switch (c) {
+ case 'w': /* "dw", "cw" */
+ vi_word_motion(command, vi_cmdmode);
+ break;
+ case 'W': /* 'dW', 'cW' */
+ vi_Word_motion(command, vi_cmdmode);
+ break;
+ case 'e': /* 'de', 'ce' */
+ vi_end_motion(command);
+ input_forward();
+ break;
+ case 'E': /* 'dE', 'cE' */
+ vi_End_motion(command);
+ input_forward();
+ break;
+ }
+ nc = cursor;
+ input_backward(cursor - sc);
+ while (nc-- > cursor)
+ input_delete(1);
+ break;
+ case 'b': /* "db", "cb" */
+ case 'B': /* implemented as B */
+ if (c == 'b')
+ vi_back_motion(command);
+ else
+ vi_Back_motion(command);
+ while (sc-- > cursor)
+ input_delete(1);
+ break;
+ case ' ': /* "d ", "c " */
+ input_delete(1);
+ break;
+ case '$': /* "d$", "c$" */
+ clear_to_eol:
+ while (cursor < len)
+ input_delete(1);
+ break;
+ }
+ }
+ break;
+ case VICMD('p'):
+ input_forward();
+ /* fallthrough */
+ case VICMD('P'):
+ put();
+ break;
+ case VICMD('r'):
+ if (safe_read(0, &c, 1) < 1)
+ goto prepare_to_die;
+ if (c == 0)
+ beep();
+ else {
+ *(command + cursor) = c;
+ putchar(c);
+ putchar('\b');
+ }
+ break;
+#endif /* CONFIG_FEATURE_COMMAND_EDITING_VI */