How do I open a file with vim from cmd?

Solution 1:

Firstly vi isn't installed by default and is not available on windows. A very good emulation of vi is available called vim, I assume for the rest of this that you have vim installed.

What you want to do is launch vim.exe from the command line without specifying the full path to the file. To do that you need to add the full path to the file's containing folder to the PATH environment variable. Here's how to do that:

Go to computer in windows explorer. Then right click on the background and select properties This should bring you to the system folder of the control panel.

In the left hand pane click Advanced system settings, click the environment variables button at the bottom of the new window that pops up.

The top pane of this window should be titled User variables for <Your Username>. Scroll through this list of user variables, and find one named path (capitalisation not important) and edit it. If there isn't a path variable on the list, then click the new button under the list to create a new variable, and name it path.

If you're creating a new path variable, simply paste the path to the containing folder as the value of the user variable. if you're editing an existing path variable you need to add a semi-colon ; character immediately followed by the path to your vim installation. the path to your vim instalation proably looks something like this: C:\Program Files (x86)\Vim\vim74

Now you should be able to use vim similarly to how you would use vi.

Solution 2:

During Vim (for Win32) install, you have the option to install batch files for launching vim from the command-line.

Solution 3:

On my system it works, the syntax is the same:

C:\>vim somefile.txt

Make sure vim is in your path. Make sure you select the console and GUI versions when installing (I think this is the default now).