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 6622817
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:27:23+00:00 2026-05-25T21:27:23+00:00

I wanted to visually mark a few lines and then surround the whole range

  • 0

I wanted to visually mark a few lines and then surround the whole range with <p> and </p>. After a lot of fiddling I have come up with this substitute command that seams to work:

:'<,'>s/^\(\_.*\)\%V/<p>\1<\/p>/

Is there a better way of doing this or could someone explain why it works?

\_. matches every characters including end-of-line. The ^ (start-of-line) and the \%V (match visual range) seams to behave strange. For example the documentation suggest that you use two \%V to surround your expression but that does not seams to be necessary. Using no \%V or having only one at the start matches the whole buffer. Removing the ^ causes the last line to be matched and substituted separately. A $ at the end seams to be unnecessary also.

  • 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-05-25T21:27:23+00:00Added an answer on May 25, 2026 at 9:27 pm

    1. Use surround vim

    You can use surround.vim, in visual mode:

    s<pEnter

    E.g. vat (visual select ‘around’ tag), s<p surround with <p>...</p>

    Breakdown:

    • vat (visually select a tag; do any visual selection you wanted)
    • s< (surround with tag), in this case, p

    2. Use ex commands with the range markers

    Edit: without surround you would be able to either

    :C-u'<iEnter<p>Esc

    :'>aEnter</p>Esc

    3. Use yank and XML filetype plugin inserting register contents:

    Or much simpler:

    dO<p>1C-r"Esc

    Note that at 1 my XML filtetype plugin (I think it is default) automatically provided the closing tag (</p>) so we can just insert the yanked contents using C-r" — without even leaving insert mode!

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

Sidebar

Related Questions

I have a table that looks like this: (so you can picture it visually)
Wanted to create a fun app with photo. This is the scenario: I have
I wanted to implement python com server using win32com extensions. Then consume the server
This is a question I have been struggling with for a while. What is
I wanted to understand how indexing in MySql works. I've few questions regarding indexing.
This question is actually inspired from another one here on SO and I wanted
I have some class that I created visually in Flash Professional CS5 by transferring
Wanted to know, because side effect of this could be to alert user that
Wanted to know if I could do this without the sub-query SELECT * FROM
I have a ListView with a specific ItemTemplate, which visually displays the contents of

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.