Reputation:
Say I want to open the file "main.cpp". I have my linux terminal open in the correct directory. Normally, I just type "vi main.cpp", but this opens the file in the shell window. How do I open the file in another window?
Upvotes: 4
Views: 10027
Reputation: 6721
You can do it using two steps:
:vs
(vertical split) or :split
(horizontal split):open
(path to filename)Upvotes: 2
Reputation: 3351
I'm not sure I understand your question. I try to answer nevertheless:
:help client-server
Thus, you create a server instance:
vim --servername foo
Afterwards you can open files in that instance from any shell via:
vim --servername foo --remote file1 file2
Or even shorter:
vim --servername vim
and vim --remote file1
(the server name 'vim' is assumed here implicitely).
EDIT: Your Vim needs to have support for the client-server architecture:
:echo has('clientserver')
should result in '1'.
Upvotes: 1
Reputation: 10074
vi is a terminal text editor. It will open in the terminal window it is called from. If you wanted an X based editor, like gVIM, then you are using the wrong editor.
Upvotes: 0
Reputation: 1535
You may want to try gvim main.cpp
which will fire up vim in its own GUI which technically will do what you're asking here.
Upvotes: 0