The problem with Ctrl-Z
When you suspend a process with Ctrl-Z, the process gets a SIGTSTP
signal, and all execution will stop (i.e., no more CPU cycles), until a SIGCONT
signal comes along. You will not be able to send vim
any commands or input while it is suspended.
In other words, don't use Ctrl-Z.
Yet if you have vim
compiled with the clientserver
feature enabled, you can make use of the --servername
and --remote-*
options:
Use vim --remote
When starting your vim
session for the first time, use vim --servername VIM [filename ...]
(filename is optional if you want to start with a blank session).
Leave it running in your terminal. Now you can control it from any other terminal window, tab, machine, etc., via vim --remote
commands. To open a file (e.g., file.txt in a new tab of your existing vim
session:
vim --remote-tab file.txt
To use vim
's internal :tabfind
functionality (see :help find
for more information):
vim --remote-send ":tabfind filename.txt<CR>"
To use your system's find(1)
program instead, as you asked in your question:
vim --remote-tab `find $PWD -name build.xml`
Multiple sessions
You can also specify a different --servername
, which is useful if you want multiple vim sessions. In that case, you need to supply the --servername
argument every time:
vim --servername HAMBURGER # Start new session named "HAMBURGER"
vim --servername HAMBURGER --remote-tab `find $PWD -name BACON`
Of course you can roll this all into a shell script or two to save yourself some typing.