In vim you can open a file under the cursor by using the gf
command.
One can also easily open that file in a new split window by hitting <c-w> f
. This is a really nice and time saving feature.
However, I can't figure out, how to open the file in an already opened split window (without creating a new one).
Best Answer
I got all the pieces together to do the trick. The best way is to create a custom mapping for all the commands:
Explanation:
map <F8>
maps on "F8" the commands that followlet mycurf=expand("<cfile>")
gets the filename under the cursor and saves it inmycurf
<c-w>w
changes the focus to the next open split windowexecute("e ".mycurf)
opens the file saved inmycurf
<c-w>p
changes the focus to the previous window (where we actually came from)