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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T06:45:13+00:00 2026-06-11T06:45:13+00:00

In Vim, I want to visually select some lines and then paste a copy

  • 0

In Vim, I want to visually select some lines and then paste a copy of the commented-out selection either above or below the original selection, depending upon whether the visual selection was created upwards or downwards. So if I start visual mode on line 100 and move the cursor up 10 lines, that would be an upward visual selection, whereas if I start at line 100 and move the cursor down 10 lines it would be a downward selection. line("'<") and line("'>") are identical in both cases so it looks like Vim always chooses the lesser number as the selection start. Is there a way to determine if the visual selection was upward or downward?

  • 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-11T06:45:15+00:00Added an answer on June 11, 2026 at 6:45 am

    When (in your mapping / command) you first exit visual mode via <Esc>, you can compare the position / line of the cursor (line('.')) with the '< and '> marks. Then just use the marks (they keep their values even when visual mode is left), or re-select via :normal! gv.

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

Sidebar

Related Questions

I want my Vim to run some commands, such as setlocal spell spelllang=en_us when
I want open a path to vim from Screen's copy-mode by Ctrl-A f similarly
I want to unwrap text in Vim. When I join lines I get an
I want match spaces at the beginning of lines in Vim PseudoCode of what
I want to be able to open Vim and automatically make some commands in
I want to draw stuff either on emacs or vim, or even in the
I want a way to pass some literal text to Vim. I've seen that
I want to do the following for multiple files using Vim: Copy all text
I want my Vim to display empty lines as a string of ### characters,
I want to extract multiple occurences of some text that spans multiple lines and

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.