3

At all times I have Tmux running, with Vim inside it. I want text files to be by default opened in that Vim instance, and not a new one. I presume I need to somehow change the default text editor as defined in ~/.selected_editor.

Primarily I need that because I also run Ranger file manager in the same Tmux instance and currently when I open a file from Ranger, it opens in a new Vim instance, which is undesirable.

The end result would comply with Vim convention of opening all files inside one instance.

1 Answer 1

4

What you describe as a convention is an honorable goal, at best, but definitely not a convention.

Vimmers usually have one or several long-running project-specific sessions with potentially dozens of buffers and short-lived sessions for quick edits. The idea is to keep related buffers together and avoid mixing unrelated concerns. Adding buffers to the long-running session is done from Vim itself and short-lived instances are just started and finished without second thoughts.

So, from a usability perspective, what you want to do is not a very good idea.

But there's the technical side of the problem. Supposing you have Vim built with the clientserver feature, you'll have to try this…

  • in one tmux pane/window:

    $ vim --servername TMUX
    
  • in another tmux pane/window:

    $ vim --serverlist
    
  • if you see the TMUX server you started in the other pane/window:

    $ vim --servername TMUX --remote filename
    

    should open filename in the TMUX instance.

  • if not, you just can't do what you want.

See :help clientserver.

1
  • This works, thank you! A good insight into running Vim as a server, too. And you are right about "convention", couldn't find the right word, but you did. Separate Vim instances for quickedits didn't work for me. But, with your answer, I can open random files for quickedit either in a separate Vim tab in that single instance (--remote-send {keys}), or in a separate Vim instance of my choice. Will accept and upvote later, perhaps someone else has an answer as well.
    – user345286
    Commented Nov 28, 2014 at 9:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .