diff options
| -rw-r--r-- | editors/vi.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/editors/vi.c b/editors/vi.c index 780c81234..0a82f9e38 100644 --- a/editors/vi.c +++ b/editors/vi.c | |||
| @@ -2072,6 +2072,11 @@ static uintptr_t stupid_insert(char *p, char c) // stupidly insert the char c at | |||
| 2072 | #endif | 2072 | #endif |
| 2073 | static char *char_insert(char *p, char c, int undo) // insert the char c at 'p' | 2073 | static char *char_insert(char *p, char c, int undo) // insert the char c at 'p' |
| 2074 | { | 2074 | { |
| 2075 | #if ENABLE_FEATURE_VI_SETOPTS | ||
| 2076 | char *q; | ||
| 2077 | size_t len; | ||
| 2078 | #endif | ||
| 2079 | |||
| 2075 | if (c == 22) { // Is this an ctrl-V? | 2080 | if (c == 22) { // Is this an ctrl-V? |
| 2076 | p += stupid_insert(p, '^'); // use ^ to indicate literal next | 2081 | p += stupid_insert(p, '^'); // use ^ to indicate literal next |
| 2077 | refresh(FALSE); // show the ^ | 2082 | refresh(FALSE); // show the ^ |
| @@ -2092,6 +2097,15 @@ static char *char_insert(char *p, char c, int undo) // insert the char c at 'p' | |||
| 2092 | if ((p[-1] != '\n') && (dot > text)) { | 2097 | if ((p[-1] != '\n') && (dot > text)) { |
| 2093 | p--; | 2098 | p--; |
| 2094 | } | 2099 | } |
| 2100 | #if ENABLE_FEATURE_VI_SETOPTS | ||
| 2101 | } else if (c == 4 && autoindent) { // ctrl-D reduces indentation | ||
| 2102 | q = begin_line(p); | ||
| 2103 | len = strspn(q, " \t"); | ||
| 2104 | if (len && q + len == p) { | ||
| 2105 | p--; | ||
| 2106 | p = text_hole_delete(p, p, ALLOW_UNDO_QUEUED); | ||
| 2107 | } | ||
| 2108 | #endif | ||
| 2095 | } else if (c == term_orig.c_cc[VERASE] || c == 8 || c == 127) { // Is this a BS | 2109 | } else if (c == term_orig.c_cc[VERASE] || c == 8 || c == 127) { // Is this a BS |
| 2096 | if (p > text) { | 2110 | if (p > text) { |
| 2097 | p--; | 2111 | p--; |
| @@ -2116,8 +2130,6 @@ static char *char_insert(char *p, char c, int undo) // insert the char c at 'p' | |||
| 2116 | showmatching(p - 1); | 2130 | showmatching(p - 1); |
| 2117 | } | 2131 | } |
| 2118 | if (autoindent && c == '\n') { // auto indent the new line | 2132 | if (autoindent && c == '\n') { // auto indent the new line |
| 2119 | char *q; | ||
| 2120 | size_t len; | ||
| 2121 | q = prev_line(p); // use prev line as template | 2133 | q = prev_line(p); // use prev line as template |
| 2122 | len = strspn(q, " \t"); // space or tab | 2134 | len = strspn(q, " \t"); // space or tab |
| 2123 | if (len) { | 2135 | if (len) { |
