0

I've got this from EmacsWiki:

(defun my/open-current-file-in-vim ()
  (interactive)
  (async-shell-command
   (format "gvim +%d %s"
           (+ (if (bolp) 1 0) (count-lines 1 (point)))
           (shell-quote-argument buffer-file-name))))

I've tried replacing gvim with vim but it opens Vim within Emacs. Is it possible to open Vim in external terminal and not show *Async Shell Command* buffer at all?

2

Yes, just adjust the shell command string to actually invoke your terminal emulator. For example with xterm:

(defun my/open-current-file-in-vim ()
  (interactive)
  (async-shell-command
   (format "xterm -e gvim +%d %s"
           (+ (if (bolp) 1 0) (count-lines 1 (point)))
           (shell-quote-argument buffer-file-name))))
| improve this answer | |
  • Thanks, that works. Is there a way not to show the async shell command buffer, I've tried giving async-shell-command nil nil after the shell command but that didn't work. This buffer is redundant especially if there is no output in it, it's basically empty. – A. Blizzard Oct 13 at 20:57
  • Also, with the new external terminal, I have a weird problem, there is a lot of overlay on the line where the cursor is as if it has wrapped around a very long line, it becomes fine after I resize/redraw the terminal window. I am using i3 window manager, I suppose it is an i3 problem, only happens with the above function. – A. Blizzard Oct 13 at 21:00
  • 1
    async-shell-command is the wrong tool for that and it shows with that buffer. Use start-process like so: (start-process "vim" nil "xterm" "-e" "vim" "+10" "/etc/passwd"). – wasamasa Oct 13 at 21:15
  • Thank you so much! – A. Blizzard Oct 13 at 21:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.