Can you substitute or delete between commas (or any arbitrary character) in vi/vim?

后端 未结 4 881
日久生厌
日久生厌 2021-02-04 16:21

For example, I have text like this:

I talked to a friend, I hiked a mountain, I am working with blah blah, 

And I want to delete or substitute

4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-04 17:13

    If you're willing to patch Vim for this feature, there was a proposal a while back (including a mostly working patch) to allow you to match arbitrary characters. In your example it would be cim, for "change inside matched comma". See https://groups.google.com/d/topic/vim_dev/pZxLAAXxk0M/discussion for the discussion and a few versions of the patch. I've been using it a long time and the only problem I've encountered is in visual mode; but then again, I don't use the feature as often as I expected to.

提交回复
热议问题