Vim Tips Wiki
(Added categories)
(Change <tt> to <code>, perhaps also minor tweak.)
 
(18 intermediate revisions by 5 users not shown)
Line 1: Line 1:
  +
{{TipImported
{{review}}
 
{{Tip
 
 
|id=716
 
|id=716
  +
|previous=714
|title=calling gvim from vc__PLUS____PLUS__ for windows.
 
  +
|next=717
|created=May 13, 2004 10:38
+
|created=2004
 
|complexity=basic
 
|complexity=basic
 
|author=mosh
 
|author=mosh
 
|version=6.0
 
|version=6.0
 
|rating=14/5
 
|rating=14/5
 
|category1=Integration
|text=
 
  +
|category2=Windows
To bring up gvim from vc++ conviniently (which I do all day,
 
 
so I ended up mapping these to function keys with gvim62):
 
 
 
 
In vc++ do menu-&gt;tools-&gt;customize-&gt;tools:
 
 
 
 
This allows single gvim window to open any file from msdev:
 
 
Name=sendtovim
 
 
Command=sendtovim.exe
 
 
Argument=&lt;c-z&gt;:cd $(FileDir)&lt;CR&gt;:e $(FilePath)&lt;CR&gt;:$(CurLine)&lt;CR&gt;
 
 
Initial Dir=$(FileDir)
 
 
 
 
If you dont like to use sendtovim.exe, try the --remote option below.
 
 
 
 
Note: &lt;c-z&gt; brings gvim to foreground - on win2k, gvim gets focus
 
 
but won't bring itself to foreground otherwise. You can remove it
 
 
if you dont have this bring-to-foreground problem.
 
 
 
 
Other possible commands you may like are:
 
 
 
 
To open a new gvim for each file:
 
 
Command=gvim.exe
 
 
Arguments=+$(CurLine) "$(FilePath)"
 
 
 
 
Notes: use quotes, when your path/files have spaces in them.
 
 
 
 
Arguments=:cd $(FileDir)&lt;CR&gt;:e $(FilePath)&lt;CR&gt;:$(CurLine)&lt;CR&gt;/\&lt;$(CurText)\&gt;&lt;CR&gt;$(CurCol)|:
 
 
 
 
This will open vim on the definition of the word under text,
 
 
for this you need to have tags file in your source tree:
 
 
 
 
Arguments=":cd $(FileDir)&lt;CR&gt;:ta $(CurText)&lt;CR&gt;/$(CurText)"
 
 
 
 
This is the client-server way:
 
 
 
 
Arguments=--remote +/"\%$(CurLine)l\%$(CurCol)v" $(FilePath)"
 
 
 
 
This lets you launch vim with a single key:
 
 
 
 
In vc++ do menu-&gt;tools-&gt;customize-&gt;keyboard-&gt;Tools-&gt;UserTool1
 
 
Current-key=&lt;Press Pause&gt;
 
 
 
 
To keep files in sync:
 
 
msdev-&gt;tools-&gt;options-&gt;editor select
 
 
1. save files before running tools
 
 
2. Automatically load externally modified files.
 
 
3. Unselect prompt before saving file.
 
 
 
 
In ~/_vimrc to update externally modified files:
 
 
:set autoread
 
 
 
 
- Mohsin
 
 
http://www.cs.albany.edu/~mosh
 
 
 
 
 
 
}}
 
}}
  +
''See [[Integrate gvim with Visual Studio]] to use vim with Visual Studio without embedding.''
  +
==Using Vim as an Internal (MDI) Window==
  +
The -P option allows you to launch gVim ''inside'' an application supporting MDI windows (such as Microsoft Visual C++). This option is somewhat buggy still, and can crash Visual Studio 6.0 if you try loading Vim with documents open in the default editor. To use it, add the following to the tools menu in Visual Studio:
   
  +
<pre>
== Comments ==
 
  +
Command: C:\Program Files\Vim\vim71\gvim.exe
I am using visvim.dll for MSVC 6.0, there is also a vim tip for using gvim with MS .net.
 
  +
Arguments: -P "Microsoft Visual C++" --servername MDI_VIM
You get additional buttons for using gvim from MSVC in addition or as replacement of the builtin editor.
 
  +
</pre>
   
  +
Name it something like "&Internal Vim" - you can now access it through the tools menu.
Thomas
 
   
  +
Notes:
'''Anonymous'''
 
  +
*If you are using Visual Studio 6.0, launch the Internal Vim tool with no documents open in the default editor, and be sure to close Vim before opening any documents in the default editor, or Visual Studio will crash. Visual Studio .NET does not have this problem.
, May 13, 2004 22:58
 
  +
*The server name is unnecessary but prevents you from accidentally sending documents to it from external sources if you use the --remote series of commands (or allows you to specify your MDI Vim instance if that's what you want to do).
----
 
  +
*The "Microsoft Visual C++" corresponds to the window title, so yours may vary. There may be an automatic way to get the window title similar to $(FilePath) above, but I don't know it.
The 6.3a beta release has a -P option which is supposed to
 
  +
*Visual Studio.NET handles an MDI Vim window much better, especially if you set the "MDI Environment" setting in Tools->Options->Environment->General. With .NET, you can actually launch the selected file in an internal Vim window automatically by adding '''<code><nowiki>+$(CurLine) "$(ItemPath)"</nowiki></code>''' to the end of the "arguments" field above. '''--remote-tab-silent''' can also be used if desired.
enable Vim to run inside any MDI application, such as visual studio.
 
  +
*The MDI window created by this call will not automatically gain input focus. Make sure Vim has focus before entering any commands!
(But, as far as I can tell, no one has been able to get it to work!)
 
  +
*Since MDI was removed from Visual Studio 2010 (including Express editions), the -P option will not work for that version. You will always receive the Vim error E671: Cannot find window title "whatever" no matter what window title you choose. Oddly enough, I did get Vim to dock with another Vim window that was open when I chose "Visual C#" as the window title (I was trying to set this up for Visual C# 2010 Express).
   
  +
===References===
  +
*{{help|-P}}
  +
*{{help|--servername}}
  +
*{{help|--remote}}
  +
*[http://msdn2.microsoft.com/en-us/library/ekbzk5f8(VS.80).aspx Visual Studio: Arguments for External Tools]
   
 
==Comments==
anon
 
, May 14, 2004 20:36
 
----
 
<!-- parsed by vimtips.py in 0.443844 seconds-->
 
[[Category:Windows]]
 
[[Category:Integration]]
 

Latest revision as of 05:44, 13 July 2012

Tip 716 Printable Monobook Previous Next

created 2004 · complexity basic · author mosh · version 6.0


See Integrate gvim with Visual Studio to use vim with Visual Studio without embedding.

Using Vim as an Internal (MDI) Window[]

The -P option allows you to launch gVim inside an application supporting MDI windows (such as Microsoft Visual C++). This option is somewhat buggy still, and can crash Visual Studio 6.0 if you try loading Vim with documents open in the default editor. To use it, add the following to the tools menu in Visual Studio:

Command: C:\Program Files\Vim\vim71\gvim.exe
Arguments: -P "Microsoft Visual C++" --servername MDI_VIM

Name it something like "&Internal Vim" - you can now access it through the tools menu.

Notes:

  • If you are using Visual Studio 6.0, launch the Internal Vim tool with no documents open in the default editor, and be sure to close Vim before opening any documents in the default editor, or Visual Studio will crash. Visual Studio .NET does not have this problem.
  • The server name is unnecessary but prevents you from accidentally sending documents to it from external sources if you use the --remote series of commands (or allows you to specify your MDI Vim instance if that's what you want to do).
  • The "Microsoft Visual C++" corresponds to the window title, so yours may vary. There may be an automatic way to get the window title similar to $(FilePath) above, but I don't know it.
  • Visual Studio.NET handles an MDI Vim window much better, especially if you set the "MDI Environment" setting in Tools->Options->Environment->General. With .NET, you can actually launch the selected file in an internal Vim window automatically by adding +$(CurLine) "$(ItemPath)" to the end of the "arguments" field above. --remote-tab-silent can also be used if desired.
  • The MDI window created by this call will not automatically gain input focus. Make sure Vim has focus before entering any commands!
  • Since MDI was removed from Visual Studio 2010 (including Express editions), the -P option will not work for that version. You will always receive the Vim error E671: Cannot find window title "whatever" no matter what window title you choose. Oddly enough, I did get Vim to dock with another Vim window that was open when I chose "Visual C#" as the window title (I was trying to set this up for Visual C# 2010 Express).

References[]

Comments[]