How do I edit text files in the Windows command prompt?

Solution 1:

edit filename

I won't vouch for its functionality and outdated GUI but it is installed by default, even on Windows 7.

Edit: Except 64 bit versions of Windows.

Solution 2:

The simplest solution on all versions of Windows is:

C:\> notepad somefile.txt

And, no extra software required.

Solution 3:

From a Windows command prompt enter copy con followed by the target file name. (copy con c:\file.txt).

Then enter the text you want to put in the file.

End and save the file by pressing CTRL-Z then Enter or F6 then Enter.

If you want to change text in an existing file simply display the text by using the command type followed by the file name and then just copy and paste the text in to the copy con command.

Solution 4:

If you're used to vi and don't want to settle for the built-in editor you can get Vim for Windows. It'll run from a command shell. Or try WinVi.

Solution 5:

If you have git installed for windows then most likely nano and vim are both available at

C:\Program Files\Git\usr\bin\nano.exe
C:\Program Files\Git\usr\bin\vim.exe

To run from a command prompt (cmd.exe)

"c:\Program Files\Git\usr\bin\nano.exe" <filename>

To run in powershell

& 'C:\Program Files\Git\usr\bin\nano.exe' <filename>

They both work great even over ssh.