How do you run Vim in Windows?

11

8

I just installed gVim, and tried using the usual "vim myfile.java" technique that usually works for linux to open up a file and edit it. But unfortunately, this doesn't seem to work. I've also tried "gvim myfile.java", but that doesn't work either.

Does anyone know how to open up vim (and use it like you do in linux) using Windows Powershell, or some other technique?

Mr Prolog

Posted 2012-04-06T21:14:13.380

Reputation:

1Maybe you could describe which install you used, as Vim has several for Windows. That would aid in getting to an answer. – pottsdl – 2012-04-06T21:42:48.753

maybe you'll need adjust your PATH variable – mightyuhu – 2012-04-06T21:46:26.753

1

Cross-posted from SO: http://stackoverflow.com/q/10049316

– Chris Johnsen – 2012-04-07T10:10:48.897

Answers

9

I run gVim by clicking an icon on my desktop or by using "edit with vim" from the context menu in Windows explorer.

If you want to invoke vim from a Windows command prompt you either need to have the path to vim.exe added to %PATH% or type the full path (e.g. "c:\program Files\gvim\vim9.9\vim.exe" foo.txt

RedGrittyBrick

Posted 2012-04-06T21:14:13.380

Reputation: 70 632

7

get the Gvim executable and install on the required system.

First, open Power shell and set alias for canonised commands (Windows 7 and above):

$ Set-alias vi "\path\to\gvim.exe"

$ Set-alias vim "\path\to\gvim.exe"

GC 13

Posted 2012-04-06T21:14:13.380

Reputation: 223

This worked perfectly for me! – simey.me – 2014-10-01T18:25:35.940

cheers ........! – GC 13 – 2014-10-03T14:56:42.180

5

The answers touch on the point that the vim directory containing the vim.exe executable need to be added to the path.

But for those needing more explicit directions, follow these procedures.

1. Open Control Panel
2. Go to System
3. Click on Advanced system settings
4. In the Advanced tab, click on Environment Variables
5. Highlight Path in System variables and click Edit...
6. At the end, enter a semicolon and add the full directory as text
    - for example, C:\Program Files (x86)\Vim\vim74
    - note that this directory must contain the executable you want to execute in command prompt i.e. vim.exe
7. Click OK and exit
8. Open new command prompt session and run vim by typing the name of the executable

Mars

Posted 2012-04-06T21:14:13.380

Reputation: 255

4

I'm pretty sure mysysgit for windows has vim, but that shell is tailored for using Git on windows, though it does have vim as far as I am aware. Quick google search found this though. Is that what you're looking for?

Thanks for the comment Zach, alternatively to restarting after having added vim to path, you can use the SET command to load up the path to the newly installed vim e.g. set path=c:\program Files\gvim\vim9.9\vim.exe so that you can restart after a normal session

Jonathan

Posted 2012-04-06T21:14:13.380

Reputation: 351

In the Vim installer that you link to, there is an option to add Vim to your PATH. This option is necessary if you want to launch vim/gvim from the command line. Once you have done that, you might need to reopen any command prompt windows, or log out and back in. – Zach – 2012-04-06T21:41:51.550

2

Windows 10

add this path to your PATH env variable C:\Program Files (x86)\Vim\vim80

  • System Properties (or Win+Break)
  • Advanced System Settings
  • Advanced Tab -> Environment Variables
  • click on Path, then [ Edit ]
  • click [ New ], and add a new variable with value: C:\Program Files (x86)\Vim\vim80

Now you can run vim from cmd or Win+R (run)

AK_

Posted 2012-04-06T21:14:13.380

Reputation: 139

2

Another option is to install Cygwin (a linux-like environment for windows) with the vim package.

http://www.cygwin.com/

During installation, search for "vim" in the package manager, and install the latest version.

Jeroen Baert

Posted 2012-04-06T21:14:13.380

Reputation: 485

0

I mostly use gVim that gets installed with the Vim chocolatey package (although this is currently fairly far behind the most recent release). This created Windows menu shortcuts for gVim and 'Edit with Vim' in the right-click menu. This has the benefit over regular Vim in that it works with a lot of Windows shortcuts and includes a menu bar with a lot of common Vim commands. Further if you want to use Vim as your full-time editor gVim is also your best bet as it handles 24-bit colours/colorscheme perfectly as well as bold/italic fonts.

I run regular Vim in the DOS prompt by installing Git from Chocolatey and then adding C:\Program Files\Git\usr\bin to my path. This gives you vim and vimdiff in the DOS prompt as well as about 250 other unix commands compiled for Windows such as ls, grep, sed and awk. Alternatively using the vim.exe that comes from the Github releases page will give you the most recent 64-bit version.

Note since Windows 10 there are big improvements being made to the DOS prompt so that using Vim instead of gVim should be a possibility:

  1. 24-bit Color in the Windows 10 console (Windows 10 release 1703 onwards)
  2. In theory Vim 8 has been patched to use the 24-bit capability of the console when using set termguicolor but I can't figure out how it works
  3. Using the ColorTool to set the colours to pretty much any iTerm colour scheme you want get's picked up by Vim. Note that I couldn't specify a particular Vim colorscheme, it was entirely dependent on the console colours - but you do get pretty excellent colours
  4. Install a TTF Powerline font, e.g. Anonymous Pro means you can enable it in the Console and get a lovely crisp font there and also get the correct icons in Vim-airline, albeit I couldn't get any of the airline theme colours to work.

enter image description here

icc97

Posted 2012-04-06T21:14:13.380

Reputation: 396