0

Question is in the title but an example will explain it better. Suppose I am editing a config file with vim and want to change this line

uid = www-data

to

uid = anotheruser

the ci" is perfect for me when the value is between quotes ( cf How to replace text between quotes in vi ) but when it's not I resort to use insert mode (for now). What would you use to get the job done faster ?

Mathias Begert
  • 2,354
  • 1
  • 16
  • 26
shrimpdrake
  • 1,476
  • 2
  • 14
  • 25

3 Answers3

2

Assuming your cursor is somewhere on www-data

I would do T<space>Canotheruser.

T{char} moves the cursor to left until the it is just after the first occurrence of {char}

C is a short hand for c$ which deletes from the cursor to the end of the line and enters insertion mode.

wywong
  • 386
  • 6
  • 12
2

As an alternative to your ci" when the text is in between quotes you could in this scenario use the WORD text-object.

Putting your cursor somewere inside www-data and press ciW

Read more about text-objects by typing :h text-objects

But personally I would use also the C command which changes the text from cursor to the end of the line, as already mentioned by others. Probably something like this /www<CR>Canotheruser<ESC>

Mathias Begert
  • 2,354
  • 1
  • 16
  • 26
0

Use c$ to delete text to the end of line.

Put cursor on the first w of uid = www-data and then use c$.

cshu
  • 5,654
  • 28
  • 44