Skip to content

Commit

Permalink
feat(normal)!: remove the default g? normal mode command
Browse files Browse the repository at this point in the history
  • Loading branch information
lewis6991 committed Apr 25, 2024
1 parent 72bae3d commit 79fd82a
Show file tree
Hide file tree
Showing 11 changed files with 18 additions and 57 deletions.
10 changes: 0 additions & 10 deletions runtime/doc/change.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions runtime/doc/index.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion runtime/doc/motion.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions runtime/doc/news.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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*

Expand Down
4 changes: 0 additions & 4 deletions runtime/doc/quickref.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions runtime/doc/vim_diff.txt
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,7 @@ Highlight groups:
<
Normal commands:
*gs*
*g?*, *g??*, *g?g?*

Options:
*'aleph'* *'al'*
Expand Down
1 change: 0 additions & 1 deletion src/nvim/ascii_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
10 changes: 0 additions & 10 deletions src/nvim/normal.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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':
Expand All @@ -5568,7 +5559,6 @@ static void nv_g_cmd(cmdarg_T *cap)
case '~':
case 'u':
case 'U':
case '?':
case '@':
nv_operator(cap);
break;
Expand Down
16 changes: 2 additions & 14 deletions src/nvim/ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand All @@ -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;
Expand All @@ -2159,15 +2152,11 @@ 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) {
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) {
if (op_type != OP_UPPER) {
nc = mb_tolower(c);
}
}
Expand Down Expand Up @@ -6213,7 +6202,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();
Expand Down
1 change: 0 additions & 1 deletion src/nvim/ops.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ 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
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
Expand Down
26 changes: 13 additions & 13 deletions test/old/testdir/test_normal.vim
Original file line number Diff line number Diff line change
Expand Up @@ -1906,19 +1906,19 @@ func Test_normal23_K()
bw!
endfunc

func Test_normal24_rot13()
" Testing for g?? g?g?
new
call append(0, 'abcdefghijklmnopqrstuvwxyzäüö')
1
norm! g??
call assert_equal('nopqrstuvwxyzabcdefghijklmäüö', getline('.'))
norm! g?g?
call assert_equal('abcdefghijklmnopqrstuvwxyzäüö', getline('.'))

" clean up
bw!
endfunc
" func Test_normal24_rot13()
" " Testing for g?? g?g?
" new
" call append(0, 'abcdefghijklmnopqrstuvwxyzäüö')
" 1
" norm! g??
" call assert_equal('nopqrstuvwxyzabcdefghijklmäüö', getline('.'))
" norm! g?g?
" call assert_equal('abcdefghijklmnopqrstuvwxyzäüö', getline('.'))
"
" " clean up
" bw!
" endfunc

func Test_normal25_tag()
CheckFeature quickfix
Expand Down

0 comments on commit 79fd82a

Please sign in to comment.