News for hackers. Stuff that matters.
Re:Vim Anti-Patterns by oolongCat on Wednesday October 05, 2016 @12:17PM (#12645200)
Instead of

  c2w
I prefer

  v2ec
selecting with v helps me avoid making mistakes.
Re:Vim Anti-Patterns by grault on Wednesday October 05, 2016 @01:19PM (#12645787)
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
Re:Vim Anti-Patterns by vacri on Thursday October 06, 2016 @02:21AM (#12650594)
ci", ci), ci]... I love these, and use them all the time.
Re:Vim Anti-Patterns by bbrik on Wednesday October 05, 2016 @12:24PM (#12645285)
The advantage of c2w is that it combines everything in a repeatable (using .) operation.
Re:Vim Anti-Patterns by oolongCat on Wednesday October 05, 2016 @01:36PM (#12645943)
and so does v2ec
Re:Vim Anti-Patterns by godd2 on Wednesday October 05, 2016 @06:01PM (#12648326)
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".