Lets say I issue :shell command from withing VI. Then I navigate to a directory and decide that I need to edit foo.txt file which I see there. Is there a way to return back to vi from the shell and have foo.txt opened for editing
Your question says vi, but your tag says vim. I don't know how to make the shell you invoke talk back to the parent Vim window, but in case the following does what you want anyway:
:E
invokes Vim's file system navigator. :help netrw
gives more information on it. From there, you can cruise around in the file system until you find the file you're interested in, press Enter
, and start editing it.
Given the following conditions are satisfied, there is a way to achieve what you want.
Vim is built with
+clientserver
. You can check this with:echo has('clientserver')
.You are in an environment that can and is properly configured to communicate with an X server.
You use the
--servername
option and a relevant argument to it when starting Vim.
In this case, you can make use of the --remote option for Vim.
An example session would be:
vim --servername foo somefile.txt
:shell
<do stuff in your shell>
vim --servername foo --remote otherfile.txt
fg