3

I am currently trying to externally add a new buffer to a vim instance from the command line.

That means I have already opened vim and I modify the files of interest to me. Then I want to go back to my bash line, so I do Ctrl + z, which makes my vim task go to the "Stopped" state.
Later I find myself to a completely irrelevant directory, wanting to edit a file. Because I don't want to open a lot of vim instances, I would like to have this added in my previous vim task (short of like most of the non-cli text editors work out there)

I am lazy. I don't want to go back to my vim instance with fg and do :edit /a/very/long/path/file

I want to do a magic add_buffer_to_vim ./file and immediately open my previous vim instance with the new buffer loaded and ready to edit.

Also I am running vim in a machine without admin rights, so installing/compiling new vi flavors is not a possibility.

I hope I am not asking for much. Thanks!

4

1 Answer 1

1

Suppose Vim is running, you can use Vim remote to send commands. I suggest to keep it running (i.e. bg after ctrl z) and then use vim --remote to send an edit command to it.

If you don't want to do this, a possible solution is to use a file that will contain a file list. Vim will check it when running and load buffers from this file.

Use au GuiEnter maybe.

2
  • Cool. I found the first approach the one more appropriate for me. Although I cannot understand why do you suggest bg after ctrl z ? To me it works the same anyway. Nov 26, 2020 at 10:36
  • I wasn't sure about the exact state of the job. It is supposedly stopped.
    – eyal karni
    Nov 26, 2020 at 22:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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