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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T15:20:47+00:00 2026-05-28T15:20:47+00:00

I often create a temporary mapping to do something on a particular file. Typical

  • 0

I often create a temporary mapping to do something on a particular file.

Typical example is this:

:map <leader>f :w<cr>:! bundle exec cucumber features/account/sign_in.feature:41<cr>

I want the file features/account/sign_in.feature to be autocompleted from the current directory.

This should simply save the current file and shell out on <leader>f to run the command.

It allows me to easily work on a piece of code not thinking about jumping to a particular file and run it.

The problem is that creating such a binding is cumbersome and error prone.

VIM doesn’t allow completing the file name when mapping. Also using % is totally different ( I want to map to a file statically).

What is a better way of doing it?

Thanks.

  • 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-28T15:20:48+00:00Added an answer on May 28, 2026 at 3:20 pm

    Allthough I think your question should be made a lot clearer, here are some hints:

    :nnoremap <leader>f :w<bar>!exec "bundle exec cucumber " . expand('%') . ":" . line('.')<CR>
    

    Will correctly save and insert current filename/line number in the command

    Also, you will want to know about the autowrite option:

    :se autowrite
    

    Lastly, I usually employ makeprg for this kind of purpose:

    :let &makeprg="bundle exec cucumber %"
    

    This has the added benefit of working with quickfix commands (:copen, :colder, :cnewer) and (given a correct makef) also jumping to error lines

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

Sidebar

Related Questions

I'll often create a file of a particular size with a trick like dd
In C++ I'd often create a code file containing constants, enums, #define-s, macros etc.
Often I create a static html prototype/skeleton for back-end developers I work with. This
In the many Python applications I've created, I often create simple modules containing nothing
I often like to create backups when testing the software I work on, and
While developing products, we often need to create proprietary tools to test some of
Often times a developer on my team will create a new Visual Studio project
Very often, I just create a new folder and test things out in there.
Based on constructor of the class. create or destroy new methods. I often requires
Here is my problem. Our tech. writer or customer service will often create new

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.