0
0
mirror of https://github.com/vim/vim.git synced 2025-09-24 03:44:06 -04:00

patch 8.1.2231: not easy to move to the middle of a text line

Problem:    Not easy to move to the middle of a text line.
Solution:   Add the gM command. (Yasuhiro Matsumoto, closes #2070)
This commit is contained in:
Bram Moolenaar
2019-10-28 02:13:05 +01:00
parent 077ff436a7
commit 8b530c1ff9
7 changed files with 57 additions and 6 deletions

View File

@@ -5979,6 +5979,24 @@ nv_g_cmd(cmdarg_T *cap)
curwin->w_set_curswant = TRUE;
break;
case 'M':
{
char_u *ptr = ml_get_curline();
oap->motion_type = MCHAR;
oap->inclusive = FALSE;
if (has_mbyte)
i = mb_string2cells(ptr, STRLEN(ptr));
else
i = (int)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. */