Take the 2-minute tour ×

When adding markup to raw text to turn it into html, wysiwyg editors let you select the piece of text you want to apply the markup to and then press something like <C-b> and get some <strong> markup around of it. It's very quick and useful.

I would like to know what options I have to do this using Vim' visual mode, and maybe make it usable only on html/jsp/php files or so. I have been looking for this for a long time. Does anyone have anything nice to share about this? Thanks in advance.

share|improve this question
add comment

2 Answers

up vote 2 down vote accepted

surround.vim should do what you want:

S<a href='/path/to/link'>
share|improve this answer
Then, if you put the following line in your vimrc, autocmd FileType html xmap <C-B> S<Lt>strong>, you can use Visual mode to select and <Ctrl-B> to emphasize in your HTML code. –  glts Nov 15 '12 at 18:39
add comment

Surround would be my choice too because it is universally useful; not only for html.

Zencoding as well can be used for that with <C-y>,.

share|improve this answer
A very nice plugin indeed :) thanks –  TKrugg Nov 25 '12 at 20:38
add comment

Your Answer


