4

I would like to be able to create and edit the text of a file, all from the command line. No pop-up window (like with notepad), just create the file and start editing. I know this can be done with Nano on Mac.

My current command line is "Command Prompt with Ruby and Rails," which I'm using on Windows 8. Apparently I have VIM installed, or VI. When I commit to git, I am entered into an excellent text edit space - within my current window. Great! But how do I do it if not committing anything, and just want to >make file>edit file>. Something like >vim file_name.

So the VIM command would be appreciated. If not available, what else can I install? I tried the Nano binary. I ran the nano.exe and it works, but calling >nano file_name from cmd doesn't work. I already copy-pasted the cygwin1.dll to the folder nano asks for in the readme. No luck. I'm using the WinNT/9x binary, .zip format download.

I'm using x64 Windows 8 OS.

3
  • 4
    Your post is very hard to follow. You seem to be talking about Windows 8, but then you are talking about VI or VIM (which are normally used in linux), Ruby on Rails, and heaven knows what else. If you are at a command prompt in Windows, you can just type Notepad <filename> and it will either create a new file of that name, or edit if the file exists. If you install another text editor, then you can similarly invoke that from the command line. But if this isn't obvious to you, please try cleaning up your post to keep to the specifics of your system.
    – Debra
    Oct 1, 2013 at 3:33
  • Thanks for the feedback, Debra. Notepad <filename> simply initiates another window, which is just the normal notepad app. I want a feature like the "edit <filename>" cmd used to have, which keeps me in my command window. -- Command P for Rails is just like the other MS CMD, they both work on Windows 8. It just has some add-ons, like ruby support and VIM/VI.
    – user258613
    Oct 1, 2013 at 4:13
  • Related post - How do I open a file with vim from cmd?
    – RBT
    Mar 20, 2019 at 8:58

5 Answers 5

5

Vim will work inside the Windows console window if you run it with vim.exe.

If you run it with gvim.exe then it will pop up a graphical window, kind of like Notepad would.

Therefore, you want to type the command vim or vim file_name and you should get what you want.

Make sure your $PATH is set to include the folder with vim.exe.

2

I always use Cygwin with Git and Vim installed to be like on a Unix term and it works perfectly (with a bashrc and alisases ....) and of course ou can install ruby and irb.

1

It just depends what editor you install. I like UltraEdit, but it's not free for long-term use. Some people like XPad, which is apparently free. There is a program called "WinVI" which is a Windows editor similar to VI, of course. You just have to decide what type of editor you want. For that matter, you could use the XP EDIT program, just copy it to Win7 from an XP system. However, I'm not sure that there's any advantage to using a text-based "DOS" style editor in Windows 7; it may look retro, but there's not likely to be any upside to it.

I think if I had to recommend something DOS-like, I'd go with Emacs-for-Windows: http://ftp.gnu.org/gnu/emacs/windows/

Whatever editor you want to use, put the installation folder into your PATH variable, which is found with Control Panel > System > Advanced System Settings > click on Environment Variables box. Select the PATH variable, and Edit, to add a colon at the end & then the path to the newly-installed program (i.e. "C:\Program Files (X86)\Editco"

This path change will then allow you to just type the program name, instead of the specific location, i.e. instead of

C:\Program Files (X86)\Editco\Myeditor.exe  filename.ext

you'd just type

Myeditor.exe filename.ext
2
  • 1
    The OP specifically mentions vim and you recommend emacs? To use a sports analogy, that's a bit like recommending to a Redsox fan that they wear a Yankees jersey. :)
    – willus
    Oct 20, 2013 at 12:22
  • Well, he said thought he had VI or VIM -installed-, not that he preferred it; in fact, he said he wanted something like the old 'edit' command that ran under 16-bit Windows. So it doesn't seem like he has any strong preference so much as wanting something "DOS-like".
    – Debra
    Oct 21, 2013 at 2:34
1

You could try one of the following options:

1
  • I can't seem to find a Windows binary at the link you provide for nano. A Google search turned out empty handed as well. Do you have any idea where I could find a Windows build of it?
    – joce
    Nov 5, 2016 at 23:28
1

edit is still available in Windows 7. Microsoft removed it in Windows 8 and up.

If you want to create a simple file from the command prompt use:

c:> copy con filename.txt

Use CTRL+Z to save the file.

You can also use echo and pipe it to a file.

You must log in to answer this question.

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