Vim Tips Wiki
(→‎Sending File to External Vim Window: remove section -- it's now on Integrate gvim with Visual Studio)
m (moved Calling gvim from MS Visual Studio to Embedding vim in Visual Studio: moved integration stuff to Integrate gvim with Visual Studio)

Revision as of 01:16, 7 August 2011

Duplicate tip

This tip is very similar to the following:

These tips need to be merged – see the merge guidelines.

Tip 716 Printable Monobook Previous Next

created May 13, 2004 · complexity basic · author mosh · version 6.0


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. Unlike the "Send To Vim" tool defined in the main part of this tip, you will need to use Vim's built-in file opening commands.

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!

References

Comments

 TO DO 

  • Needs *lots* of cleanup to be useful - dodgy perhaps?
  • Merge with tips as marked - the other ones provide similar solutions, but are focused on .NET versions of Visual Studio.

File vim71/doc/version5.txt (distributed with Vim 7.1) includes note:

Included the "SendToVim" and "OpenWithVim" programs in the OleVim directory.

File vim71/doc/version6.txt includes note:

Removed the OleVim directory and SendToVim.exe and EditWithVim.exe from the distribution.
Can now use "gvim --remote" and "gvim --remote-send", which is portable.

That is, current versions of Vim should not use SendToVim. Instead, use the --remote gvim command-line argument. See :help client-server.


visvim.dll for MSVC 6.0 gives additional buttons for using gvim from MSVC in addition to or as replacement of the built-in editor.

See the vim71/VisVim directory for files README_VisVim.txt and VisVim.dll.