Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

apply cw patch by @chrisbra to fix #6234 #6235

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion runtime/doc/motion.txt
Expand Up @@ -402,7 +402,8 @@ 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.
word does not include the following white space. This behavior can be
adjusted via |cpo-_|.

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
Expand Down
3 changes: 3 additions & 0 deletions runtime/doc/options.txt
Expand Up @@ -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)
Expand Down
6 changes: 4 additions & 2 deletions src/nvim/normal.c
Expand Up @@ -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;
}
}
Expand Down
8 changes: 5 additions & 3 deletions src/nvim/option_defs.h
Expand Up @@ -129,9 +129,11 @@
#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 '_' // do not special-case cw, it works as
// expected
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the comment seems backwards. changed this in the merge.

// default values for Vim and Vi
#define CPO_VIM "aABceFs_"
#define CPO_VI "aAbBcCdDeEfFiIJkKlLmMnoOpPqrRsStuvWxXyZ$!%+<>;_"

/* characters for p_ww option: */
#define WW_ALL "bshl<>[],~"
Expand Down