How do you run Vim in Windows?
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?
When you install
Please make sure [✓] Create .bat files for command line use is checked.
It'll create several
.bat files in
C:\>cd %windir% C:\WINDOWS>dir /b *.bat evim.bat gview.bat gvim.bat gvimdiff.bat view.bat vim.bat vimdiff.bat vimtutor.bat
C:\WINDOWS is already in the
PATH 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
After installing Vim for Windows, found here, I was able to use the vim command to open and edit files with the same commands that you would use for Vi. # Open a file vim package.json #Once the file is open, hit the “I” key to put Vim in insert mode and start editing #Once you are done editing, press esc -> : -> w -> q and enter to save your work
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,
gvim.exe was installed in the
vim74 dir for me and worked fine. So though I also needed to set the
PATH, that there was no
bat file in
C:\WiNDOWS nor any command line executable in my VIm runtime folder to call meant that calling
vim 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 of
gvim that you've already installed, dig
vim.exe out of that zip you just downloaded, and place that into the same folder as
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. ;^)
Press the ":" button to bring up the command line in the bottom of your VIM window. Type "y4" and press "enter." VIM will tell you "4 lines yanked." Move the cursor to where you want to begin your
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.
To open a new VIM window on the bottom of the currently selected window, press <Ctrl>+<w> then press <s>. You currently selected window should be split vertically as shown in the screenshot below. You can go to the window below the selected window by pressing <Ctrl>+<w> and then pressing <j>
Install gVim on your window and enable ".bat" when you install gvim and click next, done. You can use vim on window.
In the Select Components window, leave all default options checked and check any other additional components you want installed. Next, in the Choosing the default editor, used by Git unless you're familiar with Vim we highly recommend using a text editor you're comfortable using.
For Vim 6.3 and later it also includes a console version, both for MS-Windows 95/98/ME and MS-Windows NT/2000/XP/Vista/7. The installer automatically selects the right one. Runtime files vim##rt.zip vim82rt.zip(ftp)
If you want to create a Python file in .py extension and run. You can use the Windows command prompt to execute the Python code. Here is the simple code of Python given in the Python file demo.py. It contains only single line code of Python which prints the text “Hello World!” on execution.
To install vim in windows, we need to download the installer or use any of the package managers for windows. e.g Chocolatey. you can find chocolatey here if you don’t have already.
- It needs to be added in your PATH environment variable, and if I recall correctly, this requires a restart to become globally available.
- Thanks, Jay. How do you do the PATH environment variable technique?
- @MrProlog - Go to Control panel/System/Advanced/Environment Variables/ and then add it to the end in PATH variable. This is for XP, but I'm sure it's rather similar on '7.
- @Jay - Happily, you don't. You can verify it yourself, give it a try. To see all your environment variables in a command prompt just type 'set' with no arguments. So you can keep the Windows "environment variables" dialog up, add a new variable like "ZZZ" with value "foo", launch a new command prompt, and immediately see it show up. Sometimes with background services like web worker processes you have to cycle the web server, but that's just an 'iisreset', after which the new instances come up with the new environment.
- This does not answer the question that was asked. The bash for windows is still in beta. It is possible to run these type of commands from the normal windows cmd environment, which is what the question was asking for help with.
- @DeeCee I think there is already an answer to run vim from windows command prompt.The question also asks some other techniques so I just gave an alternative way.
- this works sometimes, but for me it's impractical because you have to use the WLS's code distro. that's problematic because WLS makes it extremely difficult to install packages like cx_Oracle or ROracle (database connectivity), maybe impossible in my noobish experience