Can you replace or remove a comma (or any arbitrary character) in vi / vim?

For example, I have text as follows:

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

And I want to remove or replace I hiked a mountain. Why don't they work ci,or di,? Is there a way to capture, replace, or delete between commas?

+4
source share
4 answers

There are plugins that allow you to create a custom text object. without installing plugins, suppose your cursor is between two commas, you can do:

T,c,

or

T,c,

to simulate your ci,for di,change above ctod

related reference document:

:h t
:h T
:h ,
+8
source

, , textobjectify.

vimrc , :

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

, di,, vi%, ci:, ya| ..

.

vimrc.

+5

, T,ct,.

, , vim-argumentative, ci, di,

+2

Vim , ( ), . cim, " ". . https://groups.google.com/d/topic/vim_dev/pZxLAAXxk0M/discussion . , , , - ; , , .

+1

All Articles