Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

reuse vim instance from linux terminal

By making use of the remote feature in vim, is it possible to reuse an instance of vim to load up multiple files as needed.

It will be nice to have that facility from within the same terminal instance.

I am more keen to have a tab based interface, which available in vim 7+ The scenario should be

  1. Open terminal
  2. vim file1.cpp
  3. Edit - Save - Ctrl+Z to get to prompt
  4. open another file
    • vim file2.cpp
  5. Now we have file1.cpp and file2.cpp open in the same editor

Is that possible?!

like image 541
ϹοδεMεδιϲ Avatar asked Jun 16 '09 11:06

ϹοδεMεδιϲ


1 Answers

I'm not sure if this can be done in exactly the manner that you're specifying, but something very similar can probably be done using a vim server running on your local machine.

Look into the :help remote.txt in Vim.

If your version of vim was compiled with +clientserver you can use vim to create a vim server, and then execute commands on it, e.g. opening another file.
The --servername switch can create a new server, and the --remote switch can send additional commands or files to it.

e.g.

vim --servername test file1.txt
vim --servername test --remote file2.txt

I've had a look, and the vim I'm using as standard on xubuntu on one of my computers doesn't have it, but there are some instructions here that may help if yours has it compiled. If it isn't, installing gvim and symlinking is apparently an option (as gvim has it included by default), or compiling the binaries from source.

Edit:
I've had more of a play with gvim and this doesn't look possible to do this within the terminal. Control-Z suspends the job at the process level. I thought it might work with screen, but no communication seems to take place unless gvim has launched in a graphical window,

like image 153
Andy Avatar answered Oct 15 '22 13:10

Andy