How do I change until the next underscore in VIm?

Posted by Nathan Long on Super User See other posts from Super User or by Nathan Long
Published on 2011-02-10T14:26:11Z Indexed on 2011/02/10 15:27 UTC
Read the original article Hit count: 273

Filed under:

If I have this text in vim, and my cursor is at the first character:

www.foo.com

I know that I can do:

  • cw to change up to the first period, because a word (lowercase w) ends at any punctuation OR white space
  • cW to change the whole address, because a Word (uppercase w) ends only at whitespace

Now, what if I have this:

stupid_method_name

and want to change it to this?

awesome_method_name

Both cw and cW change the whole thing, but I just want to change the fragment before the underscore.

My fallback technique is c/_, meaning 'change until you hit the next underscore in a search,' but for me, that also causes all underscores to be highlighted as search terms, which is slightly annoying.

Is there a specifier like w or W that doesn't include underscores?

© Super User or respective owner

Related posts about vim