Recently, I use Vim as my editor while programming Ruby, but I don't know if I can do that in Vim. Let's say in my Vim, I already have 2 vertical split windows named A
and B
like this:
And then I hit gf
to jump to the source file xyz.rb
if I park the cursor under the require
statement, but it will show in the same window A
by default.
Is there any shortcuts or quick combo that I can open or show the source file xyz.rb
in the opened B
split window? (and even if the window B
doesn't exist yet, create one automatically)
I've check the manual, and it does has some ways to show xyz.rb
in different horizontal split window or a new tab, but is it possible if I want to show it in specify opened split window B
.
thanks :)
The functionality you describe is already present in the form of a 'preview window'.
You could map a key (e.g. gf) to something like
:exec 'pedit ' . expand('<cfile>')
This will open the filename under the cursor in the preview window. A new preview window will be opened if none exists. See :he preview-window
for more information.
Use ^Wz (or :pclose
) to close the preview window
gf
to jump to the file and jump back by ctrl+^
, but since I have a wide monitor, why not just show the source file B in the right side split window? But sometimes the right side split window already open the other file, just like the attached image above. So, my question is: is there any way to open the file B in some split window which already exist, and not just preview, I might need it to be editable : - XXX 2012-04-05 23:18
:vs
to open a new vertical window if the split window doesn't exist, and then hit gf
to show the file. I'm just curious is there any easy way to do that : - XXX 2012-04-05 23:23
:se splitright
with ^Wf
. Also the switchbuf
option might interest you. Also consider :vert pedit
sehe 2012-04-05 23:25