vis

a vi-like editor based on Plan 9's structural regular expressions

git clone https://9o.is/git/vis.git

commit 7cbcf424f02afddf78f20510f0e648debeeaba21
parent f197364f9ef332c5efc2e606b6ffeb5b645e3f4b
Author: Matias Linares <matiaslina@opmbx.org>
Date:   Fri,  3 Apr 2015 21:27:12 -0300

Change behaviour of 'cw' and 'cW'

from vim's help:

cw cW
Special case: When the cursor is in a word, "cw" and "cW" do not include the
white space after a word, they only change up to the end of the word.  This is
because Vim interprets "cw" as change-word, and a word does not include the
following white space.

Diffstat:
Mvis.c | 8++++++++
1 file changed, 8 insertions(+), 0 deletions(-)

diff --git a/vis.c b/vis.c @@ -956,6 +956,14 @@ static void movement(const Arg *arg) { action.textobj = moves_linewise[arg->i]; else action.movement = &moves[arg->i]; + + if (action.op == &ops[OP_CHANGE]) { + if (action.movement == &moves[MOVE_WORD_START_NEXT]) + action.movement = &moves[MOVE_WORD_END_NEXT]; + else if (action.movement == &moves[MOVE_LONGWORD_START_NEXT]) + action.movement = &moves[MOVE_LONGWORD_END_NEXT]; + } + action_do(&action); }