From 1743df82f9003514c384ff99779d82179e6cb999 Mon Sep 17 00:00:00 2001 From: raichoo Date: Tue, 7 Mar 2017 23:26:21 +0100 Subject: 'cpoptions': "_" flag to toggle `cw` behaviour #6235 `cw` and `cW` behave like `ce` and `cE` respectively. This is inconsistent compared to `dw` and `dW`. Introduce a new cpoptions flag "_" to toggle the Vi behavior. Closes #6234 Patch-by: Christian Brabandt References: https://github.com/chrisbra/vim-mq-patches/blob/master/cpo_changeword https://groups.google.com/d/msg/vim_use/aaBqT6ECkA4/ALf4odKzEDgJ https://groups.google.com/d/msg/vim_dev/Dpn3xtUF16I/T6JcOPKN6usJ http://www.reddit.com/r/vim/comments/26nut8/why_does_cw_work_like_ce/ --- src/nvim/normal.c | 6 ++++-- src/nvim/option_defs.h | 7 ++++--- 2 files changed, 8 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 92b1cf2d55..d010b4b3a7 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -7193,8 +7193,10 @@ static void nv_wordcmd(cmdarg_T *cap) // Another strangeness: When standing on the end of a word "ce" will // change until the end of the next word, but "cw" will change only one // character! This is done by setting "flag". - cap->oap->inclusive = true; - word_end = true; + if (vim_strchr(p_cpo, CPO_CHANGEW) != NULL) { + cap->oap->inclusive = true; + word_end = true; + } flag = true; } } diff --git a/src/nvim/option_defs.h b/src/nvim/option_defs.h index 9c6393e014..1fd6dc9c91 100644 --- a/src/nvim/option_defs.h +++ b/src/nvim/option_defs.h @@ -129,9 +129,10 @@ #define CPO_REGAPPEND '>' /* insert NL when appending to a register */ #define CPO_SCOLON ';' /* using "," and ";" will skip over char if * cursor would not move */ -/* default values for Vim and Vi */ -#define CPO_VIM "aABceFs" -#define CPO_VI "aAbBcCdDeEfFiIJkKlLmMnoOpPqrRsStuvWxXyZ$!%+<>;" +#define CPO_CHANGEW '_' // "cw" special-case +// default values for Vim and Vi +#define CPO_VIM "aABceFs_" +#define CPO_VI "aAbBcCdDeEfFiIJkKlLmMnoOpPqrRsStuvWxXyZ$!%+<>;_" /* characters for p_ww option: */ #define WW_ALL "bshl<>[],~" -- cgit