10

I'm using windows 7.

Unix I can open a file in vi with by using:

vi textFile.txt

In windows I want to navigate to the folder and type what I have above.

What is the best way to go about this?

Thanks, Eric

1

3 Answers 3

12

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

Restart your command line tool after you have done this. Now you should be able to use vim similarly to how you would use vi.

2
  • 1
    I can confirm that this solution still works with window 10 for vim 8.2. Thanks!
    – Enis Arik
    Sep 18, 2020 at 8:09
  • No problem. This is fairly core to windows.
    – Kris Welsh
    Sep 18, 2020 at 20:57
4

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

1

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).

1
  • What needs to be in my path for windows? Vim.exe?
    – eric f
    Aug 31, 2012 at 12:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .