aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorraichoo <raichoo@googlemail.com>2017-03-07 23:26:21 +0100
committerJustin M. Keyes <justinkz@gmail.com>2017-03-10 19:24:04 +0100
commit1743df82f9003514c384ff99779d82179e6cb999 (patch)
tree1b50e6b1689d4f19f6fc913e52bb2b2c61d44cb9
parent59ea30addad61e16077eceba207db0d608dcfbe0 (diff)
downloadrneovim-1743df82f9003514c384ff99779d82179e6cb999.tar.gz
rneovim-1743df82f9003514c384ff99779d82179e6cb999.tar.bz2
rneovim-1743df82f9003514c384ff99779d82179e6cb999.zip
'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 <cblists@256bit.org> 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/
-rw-r--r--runtime/doc/motion.txt3
-rw-r--r--runtime/doc/options.txt3
-rw-r--r--runtime/doc/vim_diff.txt1
-rw-r--r--src/nvim/normal.c6
-rw-r--r--src/nvim/option_defs.h7
5 files changed, 13 insertions, 7 deletions
diff --git a/runtime/doc/motion.txt b/runtime/doc/motion.txt
index 606fd53fee..be3170cf92 100644
--- a/runtime/doc/motion.txt
+++ b/runtime/doc/motion.txt
@@ -401,8 +401,7 @@ a range of folded lines. "b" and "B" move to the start of the first word or
WORD before the fold.
Special case: "cw" and "cW" are treated like "ce" and "cE" if the cursor is
-on a non-blank. This is because "cw" is interpreted as change-word, and a
-word does not include the following white space.
+on a non-blank. This is Vi-compatible, see |cpo-_| to change the behavior.
Another special case: When using the "w" motion in combination with an
operator and the last word moved over is at the end of a line, the end of
diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt
index 25dca5fb51..e28e4e59a8 100644
--- a/runtime/doc/options.txt
+++ b/runtime/doc/options.txt
@@ -1829,6 +1829,9 @@ A jump table for the options with a short description can be found at |Q_op|.
character, the cursor won't move. When not included,
the cursor would skip over it and jump to the
following occurrence.
+ *cpo-_*
+ _ When using |cw| on a word, do not include the
+ whitespace following the word in the motion.
*'cscopepathcomp'* *'cspc'*
'cscopepathcomp' 'cspc' number (default 0)
diff --git a/runtime/doc/vim_diff.txt b/runtime/doc/vim_diff.txt
index bcc5d03ff0..bea69eb924 100644
--- a/runtime/doc/vim_diff.txt
+++ b/runtime/doc/vim_diff.txt
@@ -108,6 +108,7 @@ Some `CTRL-SHIFT-...` key chords are distinguished from `CTRL-...` variants
<C-Tab>, <C-S-Tab>, <C-BS>, <C-S-BS>, <C-Enter>, <C-S-Enter>
Options:
+ 'cpoptions' flags: |cpo-_|
'inccommand' shows interactive results for |:substitute|-like commands
'statusline' supports unlimited alignment sections
'tabline' %@Func@foo%X can call any function on mouse-click
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<>[],~"