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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T19:25:32+00:00 2026-06-06T19:25:32+00:00

In VIM, One can use % to indicate the current filename when invoking a

  • 0

In VIM, One can use % to indicate the current filename when invoking a shell command. Can Anyone point Me in the direction of documentation showing what the equivalent is in emacs?

  • 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-06T19:25:33+00:00Added an answer on June 6, 2026 at 7:25 pm

    There isn’t one. But this is Emacs! So here:

    (defun my-shell-command-on-current-file (command &optional output-buffer error-buffer)
      "Run a shell command on the current file (or marked dired files).
    In the shell command, the file(s) will be substituted wherever a '%' is."
      (interactive (list (read-from-minibuffer "Shell command: "
                                               nil nil nil 'shell-command-history)
                         current-prefix-arg
                         shell-command-default-error-buffer))
      (cond ((buffer-file-name)
             (setq command (replace-regexp-in-string "%" (buffer-file-name) command nil t)))
            ((and (equal major-mode 'dired-mode) (save-excursion (dired-move-to-filename)))
             (setq command (replace-regexp-in-string "%" (mapconcat 'identity (dired-get-marked-files) " ") command nil t))))
      (shell-command command output-buffer error-buffer))
    
    (global-set-key (kbd "M-!") 'my-shell-command-on-current-file)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am wondering how to use one hotkey mapping two command in vim. for
In Vim, one can join two lines by typing capital J. However, these are
I'm trying to use the Search command in Vim: :Rs/F/T/X R = range F
I found the window manager in vim is quite powerful. We can use it
I use Vim in Screen. I run the command vim <bigFolder> I am in
I know that when you define a function in vim, you can use the
I know that when you define a function in vim, you can use the
One of the nice things about Vim is that one can insert a page
When I switch to command mode in Vim, the cursor seems to move one
I use _vimrc to configure my vim 7.2 (windows) default settings. One setting set

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.