4

With emacs, you can use the emacsclient program to open a file in an already existing emacs frame. Is there any way to do this with vim? In other words, I want to have something I can type at the command prompt to open a file in a vim window I already have open rather than creating a new one.

  • Not your exact question, but emacs has some VIM emulation modes, at least one of which is trying to be very faithful to VIM itself. If a mostly-vim-like mode in emacs is acceptable for some of your uses, emacsclient's functionality comes along with it. – user38983 Jun 27 '16 at 18:25
7

I actually figured this one out on my own. This is supported in vim natively if you use the --remote option. Ex:

gvim --remote foo.txt

You can also specify a server name:

gvim --remote foo.txt --servername foo

I added the following function to my .zshrc (but it should work in bash as well) to make this a bit easier:

function vs() {
    gvim --remote-silent $@
}

This way, all you have to type in is vs <filename>.

7

Is there an equivalent to emacsclient for vim?

Not really.

I want to have something I can type at the command prompt to open a file in a vim window I already have open rather than creating a new one

This can be done with gvim --remote.

But emacs client is much more useful than just gvim --remote. With emacs client you can open a duplicate emacs gtk window. Then you can have emacs open with some files on your machine, ssh in with X11 forwarding and run emacsclient to pop up a emacs window on your remote machine. It's like screen for emacs. Unfortunately, gvim --remote only works to evaluate expressions, send keybindings, and open files, which while useful and matching your usecase, is not the same as emacsclient.

  • More like a comment, not an answer to op. – solotim Jan 14 '18 at 2:34

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.