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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:08:14+00:00 2026-06-11T05:08:14+00:00

I am dealing with a block of comments like: //this is comment 1 //this

  • 0

I am dealing with a block of comments like:

//this is comment 1
//this is comment 2
//this is comment 3
//this is comment 4

I would like to make it look like:

//this is comment 1

//this is comment 2

//this is comment 3

//this is comment 4

Is there a Vim shortcut to make this transformation on selected lines while staying in command mode?

  • 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-11T05:08:15+00:00Added an answer on June 11, 2026 at 5:08 am

    You can use the :substitute command. With the cursor anywhere on the
    first of the lines:

    :,+3s/$/\r
    

    This inserts an additional newline at the end of each line.

    You can also use the :global command. With the cursor anywhere on
    the first of the lines, run:

    :,+3g//norm o
    

    For each of the next four lines, this executes the o Normal-mode
    command, adding a new blank line.

    In both of the commands, the ,+3 prefix is a range for the
    command, see :help range. Briefly, the comma separates the addresses
    of the starting and ending lines of the range, where the current line
    is used if we omit the former of the two addresses. The +3 address
    refers to the line that is three lines below from the current line.

    Rather than specifying a range, e.g., ,+3, for either of these
    commands, you can use the V Normal-mode command to make a Visual
    block across all the lines that you want. Then typing : to begin the
    command will auto-fill the range specifying the visual block, and you
    can then enter either of the two commands starting with s or g:

    :'<,'>s/$/\r
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am dealing with very primitive HTML construction that goes like this: <a NAME=header1></a><b><font
When dealing with a collection of key/value pairs is there any difference between using
I use the following block of code to read lines out of a file
I want to be able to locate a block of lines in a file
I'm dealing with an issue in the Opera 11.5 beta (I am presuming this
How do people make GUIs? I mean the basic building block or principle they
Dealing with some legacy code and in trying to get a poorly designed database
Dealing with Java - which the option you prefer in the most cases -
When dealing with a series of numbers, and wanting to use hash results for
When dealing with a single file, I'm used to: /blah do some work n

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.