From 3f60ff0d5744ff3721f51e34e2f003f1fabb800d Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Thu, 25 Apr 2024 12:06:56 +0100 Subject: [PATCH] feat(normal)!: remove the default g? normal mode command Co-authored-by: zeertzjq --- runtime/doc/change.txt | 10 ---------- runtime/doc/index.txt | 3 --- runtime/doc/motion.txt | 1 - runtime/doc/news.txt | 2 ++ runtime/doc/quickref.txt | 4 ---- runtime/doc/vim_diff.txt | 1 + src/nvim/ascii_defs.h | 1 - src/nvim/normal.c | 10 ---------- src/nvim/ops.c | 24 ++++-------------------- src/nvim/ops.h | 2 +- test/old/testdir/test_normal.vim | 1 + 11 files changed, 9 insertions(+), 50 deletions(-) diff --git a/runtime/doc/change.txt b/runtime/doc/change.txt index 6d3efb41673513..0e535afe7dd2d9 100644 --- a/runtime/doc/change.txt +++ b/runtime/doc/change.txt @@ -333,16 +333,6 @@ gu{motion} Make {motion} text lowercase. gugu *gugu* *guu* guu Make current line lowercase. - *g?* *rot13* -g?{motion} Rot13 encode {motion} text. - - *v_g?* -{Visual}g? Rot13 encode the highlighted text (for {Visual} see - |Visual-mode|). - -g?g? *g?g?* *g??* -g?? Rot13 encode current line. - To turn one line into title caps, make every first letter of a word uppercase: > :s/\v<(.)(\w*)/\u\1\L\2/g diff --git a/runtime/doc/index.txt b/runtime/doc/index.txt index 79f10b33f1c000..b44239eaf31bcc 100644 --- a/runtime/doc/index.txt +++ b/runtime/doc/index.txt @@ -722,9 +722,6 @@ tag char note action in Normal mode ~ character under the cursor |g;| g; 1 go to N older position in change list |g<| g< display previous command output -|g?| g? 2 Rot13 encoding operator -|g?g?| g?? 2 Rot13 encode current line -|g?g?| g?g? 2 Rot13 encode current line |gD| gD 1 go to definition of word under the cursor in current file |gE| gE 1 go backwards to the end of the previous diff --git a/runtime/doc/motion.txt b/runtime/doc/motion.txt index e80969c583257f..0b92b9117eb78d 100644 --- a/runtime/doc/motion.txt +++ b/runtime/doc/motion.txt @@ -47,7 +47,6 @@ or change text. The following operators are available: |=| = filter through 'equalprg' or C-indenting if empty |gq| gq text formatting |gw| gw text formatting with no cursor movement - |g?| g? ROT13 encoding |>| > shift right |<| < shift left |zf| zf define a fold diff --git a/runtime/doc/news.txt b/runtime/doc/news.txt index bdfa41fba373c8..9577bd2e3466a5 100644 --- a/runtime/doc/news.txt +++ b/runtime/doc/news.txt @@ -142,6 +142,8 @@ The following changes may require adaptations in user config or plugins. • Removed the |gs| normal command. +• Removed the |g?| normal command. + ============================================================================== BREAKING CHANGES IN HEAD *news-breaking-dev* diff --git a/runtime/doc/quickref.txt b/runtime/doc/quickref.txt index c0d00d16cb0825..eb8db1e1779bc2 100644 --- a/runtime/doc/quickref.txt +++ b/runtime/doc/quickref.txt @@ -413,10 +413,6 @@ In Insert or Command-line mode: lowercase |gU| gU{motion} make the text that is moved over with {motion} uppercase -|v_g?| {visual}g? perform rot13 encoding on highlighted text -|g?| g?{motion} perform rot13 encoding on the text that is moved over - with {motion} - |CTRL-A| N CTRL-A add N to the number at or after the cursor |CTRL-X| N CTRL-X subtract N from the number at or after the cursor diff --git a/runtime/doc/vim_diff.txt b/runtime/doc/vim_diff.txt index 0e43a7358c7d8c..92fe1033f1847e 100644 --- a/runtime/doc/vim_diff.txt +++ b/runtime/doc/vim_diff.txt @@ -677,6 +677,7 @@ Highlight groups: < Normal commands: *gs* + *g?*, *g??*, *g?g?*, *v_g?* Options: *'aleph'* *'al'* diff --git a/src/nvim/ascii_defs.h b/src/nvim/ascii_defs.h index 0cd7ccfec4b745..cdb87777143a44 100644 --- a/src/nvim/ascii_defs.h +++ b/src/nvim/ascii_defs.h @@ -12,7 +12,6 @@ : (uint8_t)(x) - 'a') #define CHAR_ORD_LOW(x) ((uint8_t)(x) - 'a') #define CHAR_ORD_UP(x) ((uint8_t)(x) - 'A') -#define ROT13(c, a) (((((c) - (a)) + 13) % 26) + (a)) #define NUL '\000' #define BELL '\007' diff --git a/src/nvim/normal.c b/src/nvim/normal.c index f890069861c8e0..2e362d64a32fb1 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -3921,14 +3921,6 @@ static void nv_search(cmdarg_T *cap) oparg_T *oap = cap->oap; pos_T save_cursor = curwin->w_cursor; - if (cap->cmdchar == '?' && cap->oap->op_type == OP_ROT13) { - // Translate "g??" to "g?g?" - cap->cmdchar = 'g'; - cap->nchar = '?'; - nv_operator(cap); - return; - } - // When using 'incsearch' the cursor may be moved to set a different search // start position. cap->searchbuf = getcmdline(cap->cmdchar, cap->count1, 0, true); @@ -5559,7 +5551,6 @@ static void nv_g_cmd(cmdarg_T *cap) // "g~" Toggle the case of the text. // "gu" Change text to lower case. // "gU" Change text to upper case. - // "g?" rot13 encoding // "g@" call 'operatorfunc' case 'q': case 'w': @@ -5568,7 +5559,6 @@ static void nv_g_cmd(cmdarg_T *cap) case '~': case 'u': case 'U': - case '?': case '@': nv_operator(cap); break; diff --git a/src/nvim/ops.c b/src/nvim/ops.c index eba3e983571fe5..8cb34a4a1ca7fa 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -114,7 +114,6 @@ static char opchars[][3] = { { 'g', 'u', OPF_CHANGE }, // OP_LOWER { 'J', NUL, OPF_LINES | OPF_CHANGE }, // DO_JOIN { 'g', 'J', OPF_LINES | OPF_CHANGE }, // DO_JOIN_NS - { 'g', '?', OPF_CHANGE }, // OP_ROT13 { 'r', NUL, OPF_CHANGE }, // OP_REPLACE { 'I', NUL, OPF_CHANGE }, // OP_INSERT { 'A', NUL, OPF_CHANGE }, // OP_APPEND @@ -2131,7 +2130,6 @@ static int swapchars(int op_type, pos_T *pos, int length) /// @param op_type /// == OP_UPPER: make uppercase, /// == OP_LOWER: make lowercase, -/// == OP_ROT13: do rot13 encoding, /// else swap case of character at 'pos' /// /// @return true when something actually changed. @@ -2140,11 +2138,6 @@ bool swapchar(int op_type, pos_T *pos) { const int c = gchar_pos(pos); - // Only do rot13 encoding for ASCII characters. - if (c >= 0x80 && op_type == OP_ROT13) { - return false; - } - // ~ is OP_NOP, g~ is OP_TILDE, gU is OP_UPPER if ((op_type == OP_UPPER || op_type == OP_NOP || op_type == OP_TILDE) && c == 0xdf) { pos_T sp = curwin->w_cursor; @@ -2158,18 +2151,10 @@ bool swapchar(int op_type, pos_T *pos) } int nc = c; - if (mb_islower(c)) { - if (op_type == OP_ROT13) { - nc = ROT13(c, 'a'); - } else if (op_type != OP_LOWER) { - nc = mb_toupper(c); - } - } else if (mb_isupper(c)) { - if (op_type == OP_ROT13) { - nc = ROT13(c, 'A'); - } else if (op_type != OP_UPPER) { - nc = mb_tolower(c); - } + if (mb_islower(c) && op_type != OP_LOWER) { + nc = mb_toupper(c); + } else if (mb_isupper(c) && op_type != OP_UPPER) { + nc = mb_tolower(c); } if (nc != c) { if (c >= 0x80 || nc >= 0x80) { @@ -6213,7 +6198,6 @@ void do_pending_operator(cmdarg_T *cap, int old_col, bool gui_yank) case OP_TILDE: case OP_UPPER: case OP_LOWER: - case OP_ROT13: if (empty_region_error) { vim_beep(BO_OPER); CancelRedo(); diff --git a/src/nvim/ops.h b/src/nvim/ops.h index 1a708fab03e799..e98266e6c98f28 100644 --- a/src/nvim/ops.h +++ b/src/nvim/ops.h @@ -80,7 +80,7 @@ enum { OP_LOWER = 12, ///< "gu" make lower case operator OP_JOIN = 13, ///< "J" join operator, only for Visual mode OP_JOIN_NS = 14, ///< "gJ" join operator, only for Visual mode - OP_ROT13 = 15, ///< "g?" rot-13 encoding + // UNUSED = 15, ///< Previously used by OP_ROT13 OP_REPLACE = 16, ///< "r" replace chars, only for Visual mode OP_INSERT = 17, ///< "I" Insert column, only for Visual mode OP_APPEND = 18, ///< "A" Append column, only for Visual mode diff --git a/test/old/testdir/test_normal.vim b/test/old/testdir/test_normal.vim index 7f67dcdeb145a1..3fc1031316191a 100644 --- a/test/old/testdir/test_normal.vim +++ b/test/old/testdir/test_normal.vim @@ -1908,6 +1908,7 @@ endfunc func Test_normal24_rot13() " Testing for g?? g?g? + throw 'Skipped: Nvim has removed g?' new call append(0, 'abcdefghijklmnopqrstuvwxyzäüö') 1