Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim as the default editor

Tags:

vim

windows

I'm on Windows XP and I just installed GVim 7.3. How do I make the default editor? How can I make it run using the command prompt e.g.

c:\Windows>gvim boot.ini

open this file in gvim.

Thanks a lot

like image 644
Prakhar Avatar asked Mar 23 '11 08:03

Prakhar


2 Answers

Add Gvim to your PATH variable

To be able to call Gvim from the command line, you have to add the installation directory of Vim to your PATH variable. To do that, right click on My Computer on the desktop (or in Explorer) → Properties → Advanced Tab → Click on Button Environment Variables.

In the Dialog, go to the User Variables field and search if there is already a PATH variable. If there is a PATH Variable, select it, click Edit and change it as follows:

%PATH%;C:/Program Files/Vim/Vim73

(or whatever the installation directory of Gvim is).

If there is no PATH variable set, create a new one with the content written above.

Confirm everything with OK, then open a new command window (important!), navigate to the desired directory and type

gvim somefile.txt

This should bring up your favourite editor.


Set Gvim as default editor for a certain file type

Adding Gvim to your PATH doesn't make Gvim the default editor for a certain file type. This can be achieved the following way:

  • In Explorer, right click on any file and select Open With → Choose Program
  • in the upcoming window, select Vi improved - A Text Editor or browse for gvim.exe if the entry is not already there
  • select the Always use the selected program ... checkbox and click OK
  • from now on, every time you double-click the file, it will be opened with Gvim

The easiest way

If you install Gvim, be sure to check the Add to context menu option. If you did that, you can right click on any file in the Windows Explorer and select Edit with Vim.

like image 68
eckes Avatar answered Sep 19 '22 10:09

eckes


Right click the any file you want to open -> select Open or Open With ->check always open with the following editor.

like image 43
J Bourne Avatar answered Sep 19 '22 10:09

J Bourne