[BusyBox] patch for ^H in vi's insert mode

Paul Fox pgf at brightstareng.com
Thu Nov 4 15:30:58 UTC 2004


the following patch fixes vi so that ^H and DEL will both
properly backspace when you're in insert mode, whether or not
they're your tty erasechar.  this matches the behavior of vile and
vim.  (the patch also moves some whitespace and fixes a comment
typo.)

i also have a patch ready for cmdedit.c which adds vi commandline
editing for ash.  it adds a little over 2K on x86, and can only be
configured in addition to the existing editing mode.  i want to
use it for a few more days before submitting it, however.  (i've
only added support (via "set -o vi") to ash -- should i add it to
the other shells?  i've never used them.)

paul
=---------------------
 paul fox, pgf at brightstareng.com

diff -ru busybox-1.00.orig/editors/vi.c busybox-1.00/editors/vi.c
--- busybox-1.00.orig/editors/vi.c	2004-08-19 15:15:06.000000000 -0400
+++ busybox-1.00/editors/vi.c	2004-11-04 10:10:37.000000000 -0500
@@ -1596,7 +1596,7 @@
 		if ((p[-1] != '\n') && (dot>text)) {
 			p--;
 		}
-	} else if (c == erase_char) {	// Is this a BS
+	} else if (c == erase_char || c == 8 || c == 127) { // Is this a BS
 		//     123456789
 		if ((p[-1] != '\n') && (dot>text)) {
 			p--;
@@ -3061,8 +3061,8 @@
 		break;
 	case 'h':			// h- move left
 	case VI_K_LEFT:	// cursor key Left
-	case 8:			// ctrl-H- move left    (This may be ERASE char)
-	case 127:			// DEL- move left   (This may be ERASE char)
+	case 8:		// ctrl-H- move left    (This may be ERASE char)
+	case 127:	// DEL- move left   (This may be ERASE char)
 		if (cmdcnt-- > 1) {
 			do_cmd(c);
 		}				// repeat cnt
@@ -3225,7 +3225,7 @@
 		//
 		// dont separate these two commands. 'f' depends on ';'
 		//
-		//**** fall thru to ... 'i'
+		//**** fall thru to ... ';'
 	case ';':			// ;- look at rest of line for last forward char
 		if (cmdcnt-- > 1) {
 			do_cmd(';');



More information about the busybox mailing list