Vim Tips Wiki
No edit summary
 
(Removed {{Review}} because this still works great. Updated the version number because it works fine with vim 7.4)
Tags: Visual edit apiedit
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
  +
{{TipImported
{{review}}
 
{{Tip
 
 
|id=197
 
|id=197
  +
|previous=196
|title=Open file in already running vim from elsewhere
 
  +
|next=198
|created=January 10, 2002 23:59
+
|created=2002
 
|complexity=basic
 
|complexity=basic
 
|author=T. Zellerin
 
|author=T. Zellerin
|version=6.0
+
|version=7.4
 
|rating=133/43
 
|rating=133/43
  +
|category1=
|text=
 
  +
|category2=
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:
 
 
}}
 
If you want to edit a new file in an already-running Vim, instead of launching another instance, you may use <code>--remote</code> argument:
   
  +
<pre>
 
gvim first_file
 
gvim --remote +split first_file
  +
</pre>
   
 
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
   
  +
==References==
gvim first_file
 
 
*{{help|--remote}}
 
*{{help|--servername}}
   
 
==Comments==
gvim --remote +split first_file
 
 
Just wanted to add to this that there are built-in 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:
  +
{{script|id=180}}
   
 
 
: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
 
}}
 
 
== Comments ==
 
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
 
 
hari_vim--AT--yahoo.com
 
, January 15, 2002 16:11
 
 
----
 
----
I have the following alias in shell initialization script file (~/.bashrc)
+
I have the following alias in shell initialization script file (~/.bashrc)
   
alias gvir="gvim --remote"
+
alias gvir="gvim --remote"
   
Then, it is very convinient for me to open a file in an existing gvim window.
+
Then, it is very convenient for me to open a file in an existing gvim window.
   
$ gvir new_file
+
$ gvir new_file
   
 
 
schabungbam--AT--hss.hns.com
 
, January 24, 2002 4:02
 
 
----
 
----
If you are using some buffer manager like [/scripts/script.php?script_id=159 vimscript &#35;159] you mind find the following bash alias commands useful to start vim:
+
If you are using some buffer manager like {{script|id=159}} you might find the following bash alias commands useful to start vim:
   
alias gvdev=" gvim --servername foo --remote"
+
alias gvdev=" gvim --servername foo --remote"
alias gvlib=" gvim --servername bar --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 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.
+
You don't have to worry about pre-starting a server...if it's not found, gvim will start with that name anyway.
 
 
 
 
 
dholmes--AT--jccc.net
 
, January 24, 2003 8:17
 
----
 
great... it saves me from lot of frustration
 
   
murli
 
, April 24, 2006 1:40
 
 
----
 
----
<!-- parsed by vimtips.py in 0.487988 seconds-->
 

Latest revision as of 07:46, 10 January 2016

Tip 197 Printable Monobook Previous Next

created 2002 · complexity basic · author T. Zellerin · version 7.4


If you want to edit a new file in an already-running Vim, instead of launching another instance, you may use --remote argument:

gvim first_file
gvim --remote +split first_file

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

References[]

Comments[]

Just wanted to add to this that there are built-in 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: script#180


I have the following alias in shell initialization script file (~/.bashrc)

alias gvir="gvim --remote"

Then, it is very convenient for me to open a file in an existing gvim window.

$ gvir new_file

If you are using some buffer manager like script#159 you might 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.