Tip #197: Open file in already running vim from elsewhere
tip karma |
Rating 138/45, Viewed by 4856
|
Read and edit this tip on the
Vim tip wiki.
The wiki may have a more recent version of this tip.
created: |
|
January 10, 2002 23:59 |
|
complexity: |
|
basic |
author: |
|
T. Zellerin |
|
as of Vim: |
|
6.0 |
If you want edit new file, and you want do it in alrady running vim, instead of launching another instance, you may use --remote argument:
gvim first_file
gvim --remote +split first_file
:he --remote
It requires X windows (but works in terminal version of vim there too) or MS windows and built-in client-server mechanism. If there are several instances of vim already running, you may choose to which you talk using --servername
:help --servername
<< FileName Completion in Shell Scripts |
Pasting code with syntax coloring in emails >>
Additional Notes
[email protected],
January 15, 2002 16:11
|
Just wanted to add to this that there are builtin functions available that let you do the same thing from within running Vim session. It is cool, if you want some sample code, see the following script:
http://vim.sourceforge.net/scripts/script.php?script_id=180
|
[email protected],
January 24, 2002 4:02
|
I have the following alias in shell initialization script file (~/.bashrc)
alias gvir="gvim --remote"
Then, it is very convinient for me to open a file in an existing gvim window.
$ gvir new_file
|
[email protected],
January 24, 2003 8:17
|
If you are using some buffer manager like vimscript #159 you mind find the following bash alias commands useful to start vim:
alias gvdev=" gvim --servername foo --remote"
alias gvlib=" gvim --servername bar --remote"
You can use different names, etc...but the gist of it is that you can open different files into one or many windows. Use gvdev to open your actual scripts and gvlib to open config, headers, libraries, etc.
You don't have to worry about pre-starting a server...if it's not found, gvim will start with that name anyway.
|
murli,
April 24, 2006 1:40
|
great... it saves me from lot of frustration
|
|