aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config.def.h1
-rw-r--r--vis.c6
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 */ },
};
diff --git a/vis.c b/vis.c
index c8531e4..f82ab89 100644
--- a/vis.c
+++ b/vis.c
@@ -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);