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?
To use vim in command prompt add the vim application in the PATH variable. To do that just go to My Computer> Properties > Advanced System Settings(on the left corner) > Environment Variables There are two things: User Variable and System Variables In System variables there will be a "Path" variable, Double click on it and add the path for the vim application. For me it was:
Save it and reopen command prompt, type vim and it should work.See this image for reference
When you install
gVim
:Please make sure [✓] Create .bat files for command line use is checked.
It'll create several
.bat
files inC:\Windows\
:Notice that:
C:\WINDOWS
is already in thePATH
environment variable.When you type
vim
in command line,C:\WINDOWS\vim.bat
will be launched.If you leave the checkbox mentioned above unchecked, you need to modify
PATH
manually.Just to supplement, I'm on a fairly highly controlled Windows workstation right now, and don't have access to much. Downloading the "executable installer" that I usually use did not create the
bat
files nor, for some reason,vim.exe
, thoughgvim.exe
was installed in thevim74
dir for me and worked fine. So though I also needed to set thePATH
, that there was nobat
file inC:\WiNDOWS
nor any command line executable in my VIm runtime folder to call meant that callingvim
from the command line (or Powershell) didn't work.I'm guessing some portion of the install that's creating the command-line related stuff, apparently including
vim.exe
, isn't recovering gracefully when you don't have admin permissions.Either way, the "right" thing to do appears to be to set your
PATH
to your vim executable folder as usual (note that this might be a little more difficult than usual if you don't have admin privs), then download the "Win32 console executable" from the usual download page that matches the version ofgvim
that you've already installed, digvim.exe
out of that zip you just downloaded, and place that into the same folder asgvim.exe
.Looking on another box where the executable installer did work "fully", there's some jive in the vim.bat file that wasn't installed for me about "collect the arguments in VIMARGS for Win95" and
if .%OS%==.Windows_NT goto ntaction
, etc etc, but not having any of that doesn't seem to be a problem on Win7, at least. ;^)Windows 10 has linux subsystem for windows. So you can install bash in windows and from bash you can use vim.I found it more convenient.
Install gVim on your window and enable ".bat" when you install gvim and click next, done. You can use vim on window.