What is the proper Vim motion/action combination to perform a change or selection of a word 'patterns' while standing in the middle of it with the cursor? For example being on a second 't', like patterns.
function escape_special_patterns(text)
Are there any better options for this situation than just (for example) 4hct(
What is the proper Vim motion/action combination to perform a change or selection of a word 'patterns' while standing in the middle of it with the cursor? For example being on a second 't', like patterns.
function escape_special_patterns(text)
Are there any better options for this situation than just (for example) 4hct(
set iskeyword-=_
to remove underscore from iskeyword
and then ciw
.
The problem with this approach is how to decide when _
must be included in iskeyword
and when it must be excluded. Perhaps it's for file type plugins to decide.
Instead of trying to come up with a one size fits all solution, I'd use the small but useful commands Vim offers:
Starting with the cursor on a 't' of "patterns" (and how did you get there, anyway?), you can use T_
(or Fp
) to move back to the start of "patterns".
Then, use ve
to Visual-select until the end of the word or cw
to cut it and enter Insert mode.
Some variations do exist, all of the following will work:
T_ve
evT_
Fpve
and some more.
:help motion.txt
is your friend.
set iskeyword-=_
and thenciw
– phd Commented Feb 3 at 16:37T_cw
should do. And it's not that much longer or more complicated than any of theciw
family. – Friedrich Commented Feb 3 at 16:40_
iniskeyword
andisident
. May be you'd want to remove it only for some file types. – phd Commented Feb 3 at 18:25