Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Double vim-surround with *

Tags:

vim

Suppose my cursor is within the word word. Using vim-surround, typing the sequence ysiw* will replace word with *word*.

Question: Is there a single sequence I can type to instead produce **word** (i.e., the common markdown method for word bolding)? This opposed to typing ysiw* twice, which feels cumbersome.

like image 922
George Avatar asked Sep 24 '15 19:09

George


1 Answers

@Dan Lowe's answer about using repeat.vim and . is spot on. However you can also create custom surrounding to make common actions a bit quicker.

Add the following to your ~/.vim/after/ftplugin/markdown.vim file:

let b:surround_{char2nr('b')} = "**\r**"

Now you can do ysiwb to surround with double *'s (b for bold).

For more help customizing surroundings see :h surround-customizing.

like image 120
Peter Rincker Avatar answered Sep 24 '22 07:09

Peter Rincker