diff options
| author | Stephen Paul Weber <singpolyma@singpolyma.net> | 2014-10-19 12:24:38 +0200 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2014-10-19 12:30:55 +0200 |
| commit | b37f9e461798ba77e19ab20d7ca18555d1171e19 (patch) | |
| tree | 21f6f03638c63c8be091a1ae5049bf804d998367 | |
| parent | e036fb2faf73a590b5c119160e3fabd8844ff44c (diff) | |
| download | vis-b37f9e461798ba77e19ab20d7ca18555d1171e19.tar.gz vis-b37f9e461798ba77e19ab20d7ca18555d1171e19.tar.xz | |
Toggle case operator
In vim, :set tildeop to get this behaviour
| -rw-r--r-- | config.def.h | 1 | ||||
| -rw-r--r-- | vis.c | 6 |
2 files changed, 6 insertions, 1 deletions
diff --git a/config.def.h b/config.def.h index 9cd686a..832a975 100644 --- a/config.def.h +++ b/config.def.h @@ -217,6 +217,7 @@ static KeyBinding vis_operators[] = { { { NONE('>') }, operator, { .i = OP_SHIFT_RIGHT } }, { { NONE('<') }, operator, { .i = OP_SHIFT_LEFT } }, { { NONE('g'), NONE('U') }, changecase, { .i = +1 } }, + { { NONE('~') }, changecase, { .i = 0 } }, { { NONE('g'), NONE('u') }, changecase, { .i = -1 } }, { /* empty last element, array terminator */ }, }; @@ -616,7 +616,11 @@ static void op_case_change(OperatorContext *c) { size_t rem = len; for (char *cur = buf; rem > 0; cur++, rem--) { if (isascii((unsigned char)*cur)) { - if (c->arg->i > 0) + if (c->arg->i == 0) { + *cur = islower((unsigned char)*cur) ? + toupper((unsigned char)*cur) : + tolower((unsigned char)*cur) ; + } else if (c->arg->i > 0) *cur = toupper((unsigned char)*cur); else *cur = tolower((unsigned char)*cur); |
