Re:Vim Anti-Patterns
by oolongCat on Wednesday October 05, 2016 @12:17PM
(#12645200)
Instead of
I prefer
selecting with v helps me avoid making mistakes.
[ Parent
| on HN ]
ct" or even ci" (or ci) ci] etc) is really useful to reset the inner contents of text delimited by ")] etc.. I use these a lot - http://fuckyeahvim.tumblr.com/image/122372862496
ci", ci), ci]... I love these, and use them all the time.
The advantage of c2w is that it combines everything in a repeatable (using .) operation.
and so does v2ec
It's not the same. That will only repeat the change of the number of characters of the length of those 2 words. c2w, when repeated, will change 2 words, no matter how long the words are.
For example:
This is a string of text.
This is a string of text.
If the cursor is at the "i" of "is" on line 2, and you type v2echello<Esc>, you will have: This is a string of text.
This hello string of text.
If you move the cursor to the "s" of "string" on the first line, and press ".", you will get: This is a hellong of text.
This hello string of text.
However, if you had used c2w, it would have replaced "string of" with "hello" like so: This is a hello text.
This hello string of text.
Visual mode is lossy in terms of text objects. It only remembers counts of character movements, that's why it replaced 4 characters with "hello" instead of replacing 2 words with "hello".