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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:33:01+00:00 2026-06-18T02:33:01+00:00

Suppose I want to create a map in vim that will call an ex

  • 0

Suppose I want to create a map in vim that will call an ex command as part of its work. And suppose that the ex command takes a register name as input.

Here is a toy example:

nmap <leader>p :put x

The problem there is that the ‘x’ register will always be used.
But when typing, I want to be able to write:

"a<leader>p

To use the ‘a’ register, or:

"b<leader>p

to use the ‘b’ register.

Is there a way that I can pass the ‘current normal-mode register’ along to the ‘ex’ command?

  • 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-18T02:33:02+00:00Added an answer on June 18, 2026 at 2:33 am

    Ah, I figured it out.

    The trick is to use <expr> in the mapping.

    So, for my example, the answer is:

    nnoremap <expr> <leader>p ':put ' . v:register . '<CR>'
    

    Check :h map-expression and :h v:register for more info.

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

Sidebar

Related Questions

Suppose I want to create a custom FTP server, that is: It will look
Suppose you want to create a parent-child relationship in a table of users that
Suppose I want to create trees of a certain set depth, that is, the
I want create a web application that display a list of items. Suppose I
Suppose I’m making an Objective-C class that represents a fraction, and want to create
Hi suppose I want to create a map of the form map<int, vector<node> >
Suppose I want to create a functor that acts upon some general type. For
I want to create a model that doesn't map to a database table. Instead,
Suppose I want to create a set of observers based on type. That is
I want to create sub-domains using PHP on the fly. Suppose a user registers

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.