vim-patch:8.1.2231: introduce gM command #11321

Problem:    Not easy to move to the middle of a text line.
Solution:   Add the gM command. (Yasuhiro Matsumoto, closes vim/vim#2070)
8b530c1ff9
This commit is contained in:
Jan Edmund Lazo
2019-11-01 00:43:20 -04:00
committed by Justin M. Keyes
parent efaf4732e2
commit 471427d045
6 changed files with 52 additions and 5 deletions

View File

@@ -6749,6 +6749,22 @@ static void nv_g_cmd(cmdarg_T *cap)
curwin->w_set_curswant = true;
break;
case 'M':
{
const char_u *const ptr = get_cursor_line_ptr();
oap->motion_type = kMTCharWise;
oap->inclusive = false;
i = (int)mb_string2cells_len(ptr, STRLEN(ptr));
if (cap->count0 > 0 && cap->count0 <= 100) {
coladvance((colnr_T)(i * cap->count0 / 100));
} else {
coladvance((colnr_T)(i / 2));
}
curwin->w_set_curswant = true;
}
break;
case '_':
/* "g_": to the last non-blank character in the line or <count> lines
* downward. */