Introduction
Introduction Statistics Contact Development Disclaimer Help
tvi: ^A to search for the word under the cursor - neatvi - [fork] simple vi-typ…
git clone git://src.adamsgaard.dk/neatvi
Log
Files
Refs
README
---
commit 322e61144baa724aee78a2e257647336c65b8f77
parent ad5b762c322fa1b8512706f0b7967d4e93514164
Author: Ali Gholami Rudi <[email protected]>
Date: Fri, 22 May 2015 19:15:06 +0430
vi: ^A to search for the word under the cursor
Diffstat:
M vi.c | 31 +++++++++++++++++++++++++++++…
1 file changed, 31 insertions(+), 0 deletions(-)
---
diff --git a/vi.c b/vi.c
t@@ -399,6 +399,28 @@ static int vi_motionln(int *row, int cmd)
return c;
}
+static char *lbuf_curword(struct lbuf *lb, int row, int col)
+{
+ struct sbuf *sb;
+ char *ln = lbuf_get(lb, row);
+ char *beg, *end;
+ if (!ln)
+ return NULL;
+ beg = uc_chr(ln, ren_off(ln, ren_noeol(ln, col)));
+ end = beg;
+ while (*end && uc_kind(end) == 1)
+ end = uc_next(end);
+ while (beg > ln && uc_kind(uc_beg(ln, beg - 1)) == 1)
+ beg = uc_beg(ln, beg - 1);
+ if (beg >= end)
+ return NULL;
+ sb = sbuf_make();
+ sbuf_str(sb, "\\<");
+ sbuf_mem(sb, beg, end - beg);
+ sbuf_str(sb, "\\>");
+ return sbuf_done(sb);
+}
+
/* read a motion */
static int vi_motion(int *row, int *col)
{
t@@ -547,6 +569,15 @@ static int vi_motion(int *row, int *col)
if (vi_search(mv, cnt, row, col))
return -1;
break;
+ case TK_CTL('a'):
+ if (!(cs = lbuf_curword(xb, *row, *col)))
+ return -1;
+ strcpy(vi_findlast, cs);
+ free(cs);
+ vi_finddir = +1;
+ if (vi_search('n', cnt, row, col))
+ return -1;
+ break;
case 127:
case TK_CTL('h'):
for (i = 0; i < cnt; i++)
You are viewing proxied material from mx1.adamsgaard.dk. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.