I would like to wrap a word in Vim with enclosing tags, such as from word to 'word' or from word to (word).
I would like to wrap a word in Vim with enclosing tags, such as
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Use Tim Pope’s vim-surround, you can use:
ysw'to enclose a word with “`”,ysw(to surround the word with “(“. If you want to surround the word with an actual tag such as the HTML tag<code>, you can useyswt, then type in your tag in the prompt. If you want to change existing surround elements, usecsw, type in the surround element you want to replace and hit<CR> (enter), and type the new surrounding element.Note that for the commands above to work, you have to put the cursor in the beginning of the word you want to surround.
From its official page:
For more detailed usage info, install
vim-surround, and then use:help surroundto invoke the docs.