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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:30:08+00:00 2026-05-26T13:30:08+00:00

How would I move the current line behind the line above it? Say I

  • 0

How would I move the current line behind the line above it? Say I have:

    function foo()
      {
      ^ Cursor is here

And want to turn that into:

function foo() {

I am still new to vim, so what I do now is i[backspace][backspace]...etc. 🙂

  • 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-26T13:30:09+00:00Added an answer on May 26, 2026 at 1:30 pm

    Several ways:

    • In normal mode, kJ or kgJ or VkJ or VkgJ (the last two commands do the same in visual mode).
      k will go to previous line, and J or gJ will merge with next line (J inserts a space inbetween, gJ just removes the EOL characters)
    • In command mode, :-,j or :-,j!
      -, is a range that is abbreviation for .-1,. which means “from previous line to current line”
      j is the ex command for concatenating lines in a range. The banged (with exclamation mark) version acts like gJ.
    • With a substitution: :-s/\s*\n\s*//
      - means previous line
      :s is probably known to you, else you should run vimtutor.
      /\s*\n\s*/ is pattern for as many spaces as possible plus line terminator (matches different byte sequences according to the file format: LF, CR or CRLF) plus as many spaces as possible.
      Here, replacement pattern is empty.
    • in insert mode, hit CTRL-W twice (each time it deletes a word, or leading whitespace on a line, or newline) (as ib. suggests, this depends on the backspace setting).

    References:

    • :help J
    • :help gJ
    • :help k
    • :help range
    • :help :j
    • :help pattern
    • :help i_CTRL-W
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two XmlDocuments and I would like to move an XmlNode selected from
I have a Pylons app where I would like to move some of the
I would like to move an ID that is in an element to the
I have a jqGrid with only certain columns that are editable and I would
I'm trying to figure out what would be required to move my current blog
I have this line in a useful Bash script that I haven't managed to
I have a method that works to move the the map so that it
Say I have a list of 10,000 lines of string that needs to be
We are currently determining if we would move CVS and VSS projects to a
I would like to move a file or folder from one place to another

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.