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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T09:53:13+00:00 2026-05-19T09:53:13+00:00

I use gvim to store recipes of commands that I will execute, depending on

  • 0

I use gvim to store recipes of commands that I will execute, depending on output. Currently, I select the text in gvim and paste the commands into a terminal console, but I bet there’s a way I can pass the visually selected range into a command-line for execution.

  • 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-19T09:53:14+00:00Added an answer on May 19, 2026 at 9:53 am

    Assuming you mean the Vim command line:

    (if you mean the OS command line, see below).

    For parts of lines (i.e. no end of line character), you could do something like this:

    " Visually select lines, then:
    y:<C-R>"<ENTER>
    

    where <C-R> means press Ctrl+R. The y ‘yanks’ the selected text, the : enters command mode, <C-R>" pulls the contents of the " (last yanked text) register onto the command line and <ENTER> (obviously) runs the command.


    If you want to do line-wise stuff, it’s a bit more complicated (as the command line doesn’t like ^Ms in the command). I’d recommend something like this in your vimrc:

    function! RunCommands()
        exe getline('.')
    endfunction
    command -range RunCommands <line1>,<line2>call RunCommands()
    vmap ,r :RunCommands<CR>
    

    Select the lines (after restarting vim) and press ,r.


    Another way that you may find useful is to copy the lines you want, hit q: to open the command line window and paste the lines you want into there and then move the cursor over the line you want and press ENTER. This has the advantage that you can edit the command before pressing ENTER. It’ll only run one command at a time.

    If you mean an (e.g.) Windows or Linux command line:

    Use the function I listed above, but instead of:

    exe getline('.')
    

    use

    call system(getline('.'))
    

    or, if you want to see the result:

    echo system(getline('.'))
    

    or

    echomsg system(getline('.'))
    

    For more information:

    :help :echo
    :help :echomsg
    :help :messages
    
    :help :vmap
    :help :command-range
    :help :command
    :help :function
    
    :help c_CTRL-R
    :help :exe
    :help getline()
    :help system()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need a regular expression written to use in gVim that will remove duplicate
I've been forcing myself to use gvim for Windows for much of my text
I have a gVIM script that parses current buffer and offers user to select
I use vim (Actually gvim on windows) as my main text editor. In my
I use gvim to edit LaTex .tex file. I noticed that it checks spelling
I use gvim in windows. How do I copy text from the current position
I normally use gVim for editing, but I sometimes use vim when remotely connecting
Use case: I've just entered insert mode, and typed some text. Now I want
Use Case When a user goes to my website, they will be confronted with
I use gVim in windows to edit my code (mostly C++). I use :make

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.