Sunday, 7 July 2019

windows 7 - How do I open a file with vim from cmd?


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



Answer



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


No comments:

Post a Comment

How can I VLOOKUP in multiple Excel documents?

I am trying to VLOOKUP reference data with around 400 seperate Excel files. Is it possible to do this in a quick way rather than doing it m...