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
there are plugins to let you create customized text object. without installing plugins, assume your cursor is between two commas, you could do:
T,c,
or
t,c,
to simulate your ci,
for di,
change the above c
into d
related help doc:
:h t
:h T
:h ,
If you are in a section like that you could use T,ct,
.
Or you if you want to install a plugin like vim-argumentative allows you to use ci,
and di,
There are a bunch of plugins that help you create custom text-objects like textobjectify.
I've had the following snippet in my vimrc
for quite a while and it never failed me:
for char in [ '_', '.', ':', ',', ';', '<bar>', '/', '<bslash>', '*', '+', '%' ]
execute 'xnoremap i' . char . ' :<C-u>normal! T' . char . 'vt' . char . '<CR>'
execute 'onoremap i' . char . ' :normal vi' . char . '<CR>'
execute 'xnoremap a' . char . ' :<C-u>normal! F' . char . 'vf' . char . '<CR>'
execute 'onoremap a' . char . ' :normal va' . char . '<CR>'
endfor
It creates all the custom operator-pending mappings required for di,
, vi%
, ci:
, ya|
and so on.
And it's easy to add new delimiters.
And I have cute smileys in my vimrc
.
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.