about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--edit.c28
1 files changed, 25 insertions, 3 deletions
diff --git a/edit.c b/edit.c
index 67c35b9..15188a6 100644
--- a/edit.c
+++ b/edit.c
@@ -256,12 +256,17 @@ static int viCommand(struct Edit *e, wchar_t ch) {
 		e->vi.count += ch - L'0';
 		return 0;
 	}
+	e->vi.verb = ch;
 	switch (ch) {
 		break; case Esc: viEscape(e);
+		break; case L'$': if (e->len) e->pos = e->len - 1; viEscape(e);
 		break; case L'0': e->pos = 0; viEscape(e);
-		break; case L'R': e->vi.verb = 'R'; e->vi.mode = Insert;
-		break; case L'i': e->vi.verb = 'i'; e->vi.mode = Insert;
-		break; case L'r': e->vi.verb = 'r'; e->vi.mode = Insert;
+		break; case L'A': e->pos = e->len; e->vi.mode = Insert;
+		break; case L'I': e->pos = 0; e->vi.mode = Insert;
+		break; case L'R': e->vi.mode = Insert;
+		break; case L'a': if (e->len) e->pos++; e->vi.mode = Insert;
+		break; case L'i': e->vi.mode = Insert;
+		break; case L'r': e->vi.mode = Insert;
 	}
 	return 0;
 }
@@ -393,6 +398,17 @@ int main(void) {
 	editVi(&e, Esc);
 	assert(eq(&e, "fo\0bo"));
 
+	fix(&e, "foo");
+	vi(&e, "\33I");
+	assert(e.vi.mode == Insert);
+	assert(eq(&e, "\0foo"));
+	vi(&e, "\33A");
+	assert(e.vi.mode == Insert);
+	assert(eq(&e, "foo\0"));
+	vi(&e, "\33a");
+	assert(e.vi.mode == Insert);
+	assert(eq(&e, "foo\0"));
+
 	fix(&e, "foo bar");
 	editVi(&e, Erase);
 	assert(eq(&e, "foo ba\0"));
@@ -417,6 +433,12 @@ int main(void) {
 	assert(eq(&e, "y\0yo"));
 	vi(&e, "3rz");
 	assert(eq(&e, "yz\0z"));
+
+	fix(&e, "foo bar");
+	vi(&e, "\0330");
+	assert(eq(&e, "\0foo bar"));
+	vi(&e, "$");
+	assert(eq(&e, "foo ba\0r"));
 }
 
 #endif /* TEST */
ormatters into hilex.cJune McEnroe 2021-01-12Remove hacky tagging from hilexJune McEnroe God that makes the lexers so much simpler. 2021-01-12Add htagml -iJune McEnroe 2021-01-12Render tag index in HTMLJune McEnroe 2021-01-12Add htagml -xJune McEnroe 2021-01-12Prevent matching the same tag twiceJune McEnroe 2021-01-12Process htagml file line by lineJune McEnroe This simplifies some things, adds support for line number tag definitions, and should enable combining htagml with other preprocessors in the future. 2021-01-12Split fields by tab onlyJune McEnroe Also don't fail hard on non-forward-search definitions. 2021-01-12List both Makefile and html.sh under README.7June McEnroe 2021-01-12Add htagml exampleJune McEnroe 2021-01-12Use mandoc and htagml for bin htmlJune McEnroe 2021-01-12Add htagmlJune McEnroe 2021-01-12Replace causal.agency with a simple mdoc pageJune McEnroe 2021-01-11Publish "Using vi"June McEnroe 2021-01-11Enable diff.colorMovedJune McEnroe 2021-01-10Set less search case-insensitiveJune McEnroe 2021-01-10Set EXINITJune McEnroe neovim is laggy as hell in my OpenBSD VM, so I switched to vi so I could type without getting frustrated. 2021-01-09Add c -t flag to print expression typeJune McEnroe Also add missing float case. 2021-01-05Update taglineJune McEnroe