Turns out I move around using these a lot too. I do tend to have very
tall terminals...
---
 toys/pending/vi.c | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)
From 099ce16c8c1d179c0b107ebb66c9fe4f8343709e Mon Sep 17 00:00:00 2001
From: Elliott Hughes <[email protected]>
Date: Mon, 16 Mar 2020 17:30:16 -0700
Subject: [PATCH] vi: implement H/M/L.

Turns out I move around using these a lot too. I do tend to have very
tall terminals...
---
 toys/pending/vi.c | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/toys/pending/vi.c b/toys/pending/vi.c
index 7b4ca90b..18ce8e6a 100644
--- a/toys/pending/vi.c
+++ b/toys/pending/vi.c
@@ -751,11 +751,30 @@ static int cur_down(int count0, int count1, char *unused)
 {
   int count = count0*count1;
   for (;count--;) TT.cursor = text_nsol(TT.cursor);
-
   check_cursor_bounds();
   return 1;
 }
 
+static int vi_H(int count0, int count1, char *unused)
+{
+  TT.cursor = text_sol(TT.screen);
+  return 1;
+}
+
+static int vi_L(int count0, int count1, char *unused)
+{
+  TT.cursor = text_sol(TT.screen);
+  cur_down(TT.screen_height-1, 1, 0);
+  return 1;
+}
+
+static int vi_M(int count0, int count1, char *unused)
+{
+  TT.cursor = text_sol(TT.screen);
+  cur_down(TT.screen_height/2, 1, 0);
+  return 1;
+}
+
 static int search_str(char *s)
 {
   size_t pos = text_strstr(TT.cursor+1, s);
@@ -1106,10 +1125,13 @@ struct vi_mov_param vi_movs[] =
   {"b", 0, &vi_movb},
   {"e", 0, &vi_move},
   {"G", 0, &vi_go},
+  {"H", 0, &vi_H},
   {"h", 0, &cur_left},
   {"j", 0, &cur_down},
   {"k", 0, &cur_up},
+  {"L", 0, &vi_L},
   {"l", 0, &cur_right},
+  {"M", 0, &vi_M},
   {"w", 0, &vi_movw},
   {"$", 0, &vi_eol},
   {"f", 1, &vi_find_c},
-- 
2.25.1.481.gfbce0eb801-goog

_______________________________________________
Toybox mailing list
[email protected]
http://lists.landley.net/listinfo.cgi/toybox-landley.net

Reply via email to