On Unix I'd just use vi, but I don't know what the command is on Windows. I am actually trying to edit files over SSH with Windows Server 2008.
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.
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.
Believe it or not,
EDLIN.EXE is still around
<shudder> at least on this Vista system.
Excuse me while I sob softly to myself...
I don't know about SSH, or anything (else?) server-related, so forgive me if this "solution" is useless. If you want to edit files in the command prompt, you can get the Windows version of Nano.
As a side note, those little
^ signs at the bottom of the window are supposed to represent the Ctrl button. For instance,
^X Exit means that you can exit the program using Ctrl-X.
Also, Nano will sometimes add extra newlines when saving files. This seems to be some kind of bug with Nano's word wrapping.
I've also seen ports of vi for Windows, although I've used one that just seem to make command prompt window as small as it can be, leaving only a title bar (which means the rest of the window may as well be invisible, since you can't see what you're doing). However, the Windows version of Vim seems to work quite nicely.
As @phuclv has mentioned in comments, I want to emphasize that there is a tool that actually works great on Windows 64 bit too! It's called Micro and fortunately, it is quite feature-rich, regularly updated and alive.
To install it, you only need to download the latest version's 64bit.zip file from here, and then unzip it somewhere and add its path to your PATH. No dependencies or external files are needed — just the binary and you're done.
- Just type
microto create and edit a new text file.
micro <filename>to start editing an already-made file.
- To save:
ctrl + s
- To see a list of keybindings:
alt + g
- To quit:
ctrl + q
Some Exciting Features:
- Select text easily (using the shift key, or even using your mouse!), and then copy, cut, paste or delete the selected text using the same keybindings common in your operating system(e.g.
ctrl + cfor copy on Windows).
- Supporting so many common keybindings, e.g.
ctrl + dto duplicate a line, or activate multiple curser mode and etc.
- Undo / Redo
- Syntax Highlighting (for more than 130 programming languages)
- Plugin System
- Typed Commands (instead of using keybindings)
A tip on using Micro for VSCode users:
Since both VSCode and Micro try to support all common keybindings, you'll probably have a lot of conflicting keybindings between them when using Micro inside the VSCode's embedded CMD/PowerShell terminal. For instance, to quit Micro, you will have to use
ctrl + q while it is the VSCode's keybinding for the "Quick Open View" command.
But no worries! Micro also supports "Typed Commands" which allow you to control the editor using commands instead of keybindings. So you can type commands and you're fine to use Micro on VSCode as well. However, there's still a tiny problem. To enable "command mode" on Micro, you have to use
ctrl + e, which is also a keybinding of VSCode for the "Go To File..." command. So you have to change the
ctrl + e keybinding either on VSCode or on Micro to get rid of this conflict and then you're all set.
Personally, I preferred to change Micro's
ctrl + e. Here are the steps from the documentation to change it to
ctrl + w (or whatever else non-conflicting keybinding of your own liking) on a Windows machine:
%userprofile%/.config/micro/bindings.jsonwith any editor.
- Add this line to the end of the JSON:
Now to enter command mode, press
ctrl + wand type your commands (e.g.: quit, save, open, etc).
Use vim or nano.
Install vim with with
choco install vim using the chocolatey package manager.
(There might be Scoop version available as well, but I haven't checked.)
Although nano also exists as choco package, it is very outdated. Instead manually install this nano. However, when using over SSH, nano control characters get a bit confused, so you may lose some, since windows use it's own API for controlling screen characters, and not POSIX. So although a lot of work is currently in progress for future Win10 compatibility.
Then you can run with:
nano -cg some.txt, but the cursor will only show up at the right location when you push
CTRL-L. (Which is why vim is preferred.)
If the remote computer has Windows Subsystem for Linux installed, you can type
bash to have the next commands interpreted by WSL. From here, you can type
nano FILENAME or
vim FILENAME or whatever your preferred Linux text editor is. To exit WSL and return to regular Command Prompt, type
This came in handy when I was accessing a Windows Jupyter Notebook server and wanted to edit
.gitattributes, a hidden file which isn't shown in the Jupyter GUI. This answer is based on SajanGohil's comment above.
I'm not 100% sure it will work via SSH as they may use some special Windows API for Console Window management, but on Windows there is a console shell called FAR Manager (similar to Norton Commander or Volkov Commander for MS DOS or Midnight Commander for Linux). You can run the FAR Manager editor using the following command line:
far -E <filename>