diff --git a/src/ex.c b/src/ex.c index 5ac8583e..3f5e305c 100644 --- a/src/ex.c +++ b/src/ex.c @@ -1056,8 +1056,8 @@ static VbCmdResult ex_register(Client *c, const ExArg *arg) for (idx = 0; idx < REG_SIZE; idx++) { /* show only filled registers */ if (c->state.reg[idx]) { - /* replace all newlines */ - reg = util_str_replace("\n", "^J", c->state.reg[idx]); + /* replace all newlines with enough spaces to align nicely */ + reg = util_str_replace("\n", "\n ", c->state.reg[idx]); g_string_append_printf(str, "\n\"%c %s", regchars[idx], reg); g_free(reg); } diff --git a/src/main.c b/src/main.c index 557a9fea..728c5712 100644 --- a/src/main.c +++ b/src/main.c @@ -527,17 +527,30 @@ void vb_register_add(Client *c, char buf, const char *value) { char *mark; int idx; + bool shouldAppend = false; if (!c->state.enable_register || !buf) { return; } + /* check if its capital letter, if yes - append, don't overwrite */ + if(buf >= 'A' && buf <= 'Z') { + shouldAppend = true; + // 32 is the magic number - ASCII offset from start of uppercase + // to lowercase letters + buf = buf + 32; + } + /* make sure the mark is a valid mark char */ if ((mark = strchr(REG_CHARS, buf))) { /* get the index of the mark char */ idx = mark - REG_CHARS; - OVERWRITE_STRING(c->state.reg[idx], value); + gchar* newcontents = value; + if(shouldAppend && c->state.reg[idx]) + newcontents = g_strjoin("\n", c->state.reg[idx], value, NULL); + + OVERWRITE_STRING(c->state.reg[idx], newcontents); } } diff --git a/src/main.h b/src/main.h index 9e934778..b8eaf9ee 100644 --- a/src/main.h +++ b/src/main.h @@ -63,7 +63,7 @@ #define GLOBAL_MARK_CHARS "'ABCDEFGHIJKLMNOPQRSTUVWXYZ" -#define USER_REG "abcdefghijklmnopqrstuvwxyz" +#define USER_REG "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" /* registers in order displayed for :register command */ #define REG_CHARS "\"" USER_REG ":%/;" #define REG_SIZE (sizeof(REG_CHARS) - 1)