busybox/editors
Ron Yorston 9659a8db1d vi: remove autoindent from otherwise empty lines
Lines that have no content apart from automatic indentation should
be treated as empty when the user hits return or ESC.

The implementation uses the global variable 'indentcol'.  Usually
this is zero.  It can also be -1 to indicate an 'O' (open above)
command, replacing the overloading of the tabstop option bit.

A value greater than zero indicates that the current line has
been autoindented to the given column (or that the autoindent has
been adjusted with ctrl-D).  Any other change to the line resets
'indentcol' to zero.

Replace strspn() with ident_len().  The latter handles the unlikely
case that it's called on the last line of a file which doesn't have
a terminating newline.

function                                             old     new   delta
char_insert                                          741     912    +171
indent_len                                             -      42     +42
do_cmd                                              4781    4785      +4
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 2/0 up/down: 217/0)             Total: 217 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-06-02 06:29:34 +02:00
..
awk.c awk: allow printf('%c') to output NUL, closes 13486 2021-02-02 13:51:14 +01:00
cmp.c config: update size information 2018-12-28 03:20:17 +01:00
Config.src restore documentation on the build config language 2018-06-06 15:16:48 +02:00
diff.c diff: code shrink 2021-02-22 19:00:07 +01:00
ed.c libbb: introduce and use fputs_stdout 2021-02-03 20:52:40 +01:00
Kbuild.src switch editors/* to embedded-in-source kbuild system 2013-11-13 12:45:33 +01:00
patch_bbox.c libbb: reduce the overhead of single parameter bb_error_msg() calls 2019-07-02 11:35:03 +02:00
patch_toybox.c libbb: reduce the overhead of single parameter bb_error_msg() calls 2019-07-02 11:35:03 +02:00
patch.c help text: replace [OPTIONS] with actual options (if not too long) 2020-12-13 22:34:05 +01:00
sed1line.txt
sed_summary.htm
sed.c libbb: reduce the overhead of single parameter bb_error_msg() calls 2019-07-02 11:35:03 +02:00
vi.c vi: remove autoindent from otherwise empty lines 2021-06-02 06:29:34 +02:00