3

In vim, what is the character command sequence to put the same character before and after a word. I think there's a way to do it but I forget.

Say I have the word candy and I want to make it =candy=. Isn't there command sequence to do this more efficiently than entering insert mode twice?

firebush
  • 5,180
  • 4
  • 34
  • 45

1 Answers1

6

There is a plugin called tpope/vim-surround that makes this easier. In your case, it would be ysiw= (or ysw= if you're at the beginning of the word). This plugin also supplies convenient mappings for deleting and changing surrounding characters. In my opinion, this is one of those essential vim plugins. I can't imagine not installing it.

However, if you don't want to install a plugin, the shortest approach I'm aware of would be

ciw==<esc>P

This is one keystroke shorter than

bi=<esc>ea=<esc>
DJMcMayhem
  • 7,285
  • 4
  • 41
  • 61