Skip to content

Commit d04cc55

Browse files
brammooldouglaskayama
authored andcommitted
patch 7.4.754 Problem: Using CTRL-A in Visual mode does not work well. (Gary Johnson) Solution: Make it increment all numbers in the Visual area. (Christian Brabandt)
1 parent 2c03ee0 commit d04cc55

12 files changed

Lines changed: 490 additions & 193 deletions

File tree

src/normal.c

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4206,9 +4206,17 @@ nv_help(cap)
42064206
nv_addsub(cap)
42074207
cmdarg_T *cap;
42084208
{
4209-
if (!checkclearopq(cap->oap)
4210-
&& do_addsub((int)cap->cmdchar, cap->count1) == OK)
4209+
int visual = VIsual_active;
4210+
if (cap->oap->op_type == OP_NOP
4211+
&& do_addsub((int)cap->cmdchar, cap->count1, cap->arg) == OK)
42114212
prep_redo_cmd(cap);
4213+
else
4214+
clearopbeep(cap->oap);
4215+
if (visual)
4216+
{
4217+
VIsual_active = FALSE;
4218+
redraw_later(CLEAR);
4219+
}
42124220
}
42134221

42144222
/*
@@ -7875,14 +7883,28 @@ nv_g_cmd(cap)
78757883

78767884
switch (cap->nchar)
78777885
{
7886+
case Ctrl_A:
7887+
case Ctrl_X:
78787888
#ifdef MEM_PROFILE
78797889
/*
78807890
* "g^A": dump log of used memory.
78817891
*/
7882-
case Ctrl_A:
7883-
vim_mem_profile_dump();
7884-
break;
7892+
if (!VIsual_active && cap->nchar == Ctrl_A)
7893+
vim_mem_profile_dump();
7894+
else
78857895
#endif
7896+
/*
7897+
* "g^A/g^X": sequentially increment visually selected region
7898+
*/
7899+
if (VIsual_active)
7900+
{
7901+
cap->arg = TRUE;
7902+
cap->cmdchar = cap->nchar;
7903+
nv_addsub(cap);
7904+
}
7905+
else
7906+
clearopbeep(oap);
7907+
break;
78867908

78877909
#ifdef FEAT_VREPLACE
78887910
/*

0 commit comments

Comments
 (0)