Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7846211
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T17:30:11+00:00 2026-06-02T17:30:11+00:00

I would like to wrap a word in Vim with enclosing tags, such as

  • 0

I would like to wrap a word in Vim with enclosing tags, such as from word to 'word' or from word to (word).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T17:30:12+00:00Added an answer on June 2, 2026 at 5:30 pm

    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 use yswt, then type in your tag in the prompt. If you want to change existing surround elements, use csw, 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:

    Press cs"' (that’s c, s, double quote, single quote) inside

    “Hello world!”

    to change it to

    ‘Hello world!’

    Now press cs'<q> to change it to

    Hello world!

    To go full circle, press cat" to get

    “Hello world!”

    To remove the delimiters entirely, press ds" .

    Hello world!

    Now with the cursor on “Hello”, press ysiw] (iw is a text object).

    [Hello] world!

    Let’s make that braces and add some space (use “}” instead of “{” for no space): cs]{

    { Hello } world!

    Now wrap the entire line in parentheses with yssb or yes) .

    ({ Hello } world!)

    Revert to the original text: ds{ds)

    Hello world!

    Emphasize hello: ysiw<em>

    Hello world!

    Finally, let’s try out visual mode. Press a capital V (for linewise visual mode)
    followed by S<p class="important">.

    Hello world!

    For more detailed usage info, install vim-surround, and then use :help surround to invoke the docs.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to Find word on page, wrap in span tags with class.
I would like to have a function that can wrap any other function call.
I would like to create this layout in Silverlight. The text need to wrap
Would like to be able to set colors of headings and such, different font
I would like to parse the values from aspx pages, both what is passed
I'm working on a web project where I would like to clear text from
I would like to wrap a java program into a windows service with C#
I would like to wrap the String.format() method with in my own Logger class.
Hi I would like to wrap the following comma separated data: -X, run, abs,
Suppose I'm given a class A . I would like to wrap pointers to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.