1 From 0221708f0f7147c84c8f7288e9c510241d296a4c Mon Sep 17 00:00:00 2001
2 From: Dennis Groenen <tj.groenen@gmail.com>
3 Date: Sun, 22 Jan 2012 20:15:21 +0100
4 Subject: [PATCH] vi: implement :p (go to previous file)
7 editors/vi.c | 8 ++++++++
8 1 files changed, 8 insertions(+), 0 deletions(-)
10 diff --git a/editors/vi.c b/editors/vi.c
11 index 4a2d5d4..ddca9d6 100644
14 @@ -1111,6 +1111,7 @@ static void colon(char *buf)
16 } else if (strncmp(cmd, "quit", i) == 0 // quit
17 || strncmp(cmd, "next", i) == 0 // edit next file
18 + || strncmp(cmd, "prev", i) == 0 // edit previous file
22 @@ -1137,6 +1138,13 @@ static void colon(char *buf)
23 status_line_bold("No more files to edit");
26 + // are there previous files to edit
27 + if (*cmd == 'p' && optind <= 1) {
28 + status_line_bold("No previous files to edit");
30 + } else if (*cmd == 'p' && optind > 1) {
31 + optind = optind - 2;
34 } else if (strncmp(cmd, "read", i) == 0) { // read file into text[]