Wanted, Dead or Alive: CLI Editor
This article was inspired by the page Wanted: Console Text Editor for Windows, which is very thorough and I strongly recommend that you read it (while you’re at it, put a star in the Github profile of the author, Antoni Sawicki); however, I discovered so many things in the meantime that I decided maybe I can give my two cents about this.
The original article begins with what are also my reasons to investigate this issue:
Since 2012 or so Microsoft is pushing concept of running Windows Server headless without GUI and administering everything through PowerShell. I remember sitting through countless TechEd / Ignite sessions year after year and all I could see were blue PowerShell command prompts everywhere. No more wizards and forms, MMC and GUI based administration is suddenly thing of a past. Just take a look at Server Core, WinPE, Nano, PS Remoting, Windows SSH server, Recovery Console and Emergency Management Services. Even System Center is a front end for PowerShell. Nowadays everything seems to be text mode.
This overall is good news and great improvement since previous generations of Windows, but what if you need to create or edit a PowerShell, CMD script or some config file?
Exactly!
The first time I stumbled upon this need was when I needed to edit a configuration file from a package ported from *NIX - and Notepad didn’t even support UNIX line breaks, so I had to install Notepad++, nothing against it, wonderful application, if only it was multiplatform - but I was left wondering:
What if my only option had been remote access by CLI?
And yes, in the latest Windows (client) there’s the Windows Subsystem for Linux (WSL), with direct access to Windows' native file systems, but also the full set of shells and utilities for *NIX. But there’s no WSL in Windows Server…
Evaluation parameters
I have some criteria that helped me eliminate a substantial amount of candidates:
- Free and/or for free use, even in professional applications
- x64 compatible
- Support *NIX and DOS line endings
- UTF-8 support
- Being able to run from an executable with a minimum of installation (not spreading 400 files throughout the system disk, for example)
Test system
The editors were summarily tested in Windows 10, but the installation process documented in this article was done in Windows Server Core 2022 (although there shouldn’t be any big difference in Server 2019).
Simple editor
This type of editors has very basic features, having especially limited Search and Replace, and rarely offering things like syntax highlighting; their purpose is to open a text file, change two lines and close it. Being on DOS/Windows, they should follow the CUA (Common User Access) interface standard, developed for OS/2 and used in all Microsoft applications, particularly EDIT.COM which was released with MS-DOS 5.
EDIT.EXE
The latter is the same EDIT.EXE which is still available in some versions of Windows. But since it’s a 16-bit program, it only runs in x86 versions of Windows. I tested it with version 20H02, which was still made available in x86, but Windows 10 OEM stopped having x86 versions since 20H01, also known as 2004.
Before attempting to run the command, we need to go to CMD.EXE’s Properties, tab Options and enable Legacy Console; then close and re-open CMD.EXE.
When you try to run the executable for the first time, Windows asks for permission to install a library, NTVDM, which is the NT Virtual DOS Machine
After meeting these requirements, we’re able open the good old MS-DOS Editor - but of course it doesn’t work in x64, doesn’t know what *NIX line endings are and can’t even imagine what UTF-8 is, but it’s there…
The last version of Windows Server with x86 support is Windows Server 2008, based on Vista.
YEdit
YEdit is part of the shell utilities package / shell replacement Yori
It’s possible to run YEdit without Yori, but first you need to download Yori, as I’ll demonstrate.
Yori’s installer is just a stub that downloads the latest version directly from the repository; however, although this is a good idea (the installer is always the same and it’s not necessary to rebuild it for each new version), this mode of operation, added to the fact that the installer isn’t signed, makes all anti-malware protections scream (warnings on the browser, SmartScreen, Windows Defender, etc.) if we are in a Windows (Client); but when logged in as Administrator on a Windows Server, nothing happens.
YEdit is compatible with x64 e UTF-8, which is most important, but it is also possible to specify a Code Page (remember those?) to open those files that got left behind in the previous century.
For more information about YEdit, the same author of the original article has made another article specifically on Yedit: Yedit – The missing edit.com replacement for modern Windows
For my part, after solving the installation issues, it runs on Windows x64 and supports UTF-8, so it’s been approved…
Installing
For easier access, these editors can be copied to a folder on the user’s profile like %LOCALAPPDATA%\Microsoft\WindowsApps\
; this folder is used by Microsoft to place shortcuts to the actual location of many executables such as winget
, Windows Terminal (wt.exe
), Edge, etc.
There’s no Microsoft Store on Windows Server but the folder is there just the same and it’s part of the PATH variable.
Download the installer:
|
|
And install directly:
|
|
Obtaining package URLs... Installing 1 of 4: http://www.malsmith.net/download/?obj=yori/latest-stable/yori-ypm-amd64.cab Installing 2 of 4: http://www.malsmith.net/download/?obj=yori/latest-stable/yori-core-amd64.cab Installing 3 of 4: http://www.malsmith.net/download/?obj=yori/latest-stable/yori-typical-amd64.cab Installing 4 of 4: http://www.malsmith.net/download/?obj=yori/latest-stable/yori-completion-noarch.cab Applying installation options... Installation complete. Success: Installation complete.
Although $ENV:LocalAppData\Microsoft\WindowsApps\
is part of each user’s private PATH since Windows 8, its subfolders are not (and it wouldn’t have been nice to drop Yori at the root of the folder); this why we must add the path where we installed Yori to PATH:
|
|
And finally yedit
Like I said, yedit.exe
can be used standalone without Yori, after the latter has been installed; in this case, don’t add Yori’s folder to the PATH - but since we did, let’s undo it:
|
|
To make everybody’s lives easier, I’ll make available the executable for YEdit 1.70; just drop it on $ENV:LocalAppData\Microsoft\WindowsApps\
or any other folder that is part of your PATH.
yedit.exe v1.70 - (c) Malcolm Smith
But once again, I recommend that you try the entire Yori package, because it’s really good.
About Yori
A small comment about Yori: I don’t know where Yori has been my whole life, but it’s fantastic. It’s what CMD.EXE ought to have been for 20 years, and is an excellent option if you want a more powerful shell without having to migrate to PowerShell or install 1GB of WSL just to access *NIX shells. Here’s a small sample of the available commands:
Wishlist: Tilde
In the *NIX world the opposite just happened, because someone developed a simple editor with the typical Windows' CUA interface, which is more natural for those who move from a GUI to the CLI. This editor is called Tilde and currently does not have a version for Windows.
It would be nice to have two options …
Advanced Editor
These editors are more powerful and have a steeper learning curve than simpler editors like Notepad:
But they usually have advanced functions such as macros, multiple windows, syntax highlighting, plugins, etc.
We’ll start with the classic *NIX editors: Pico (Nano), VI (VIM), JOE e EMACS :
Pico/Nano: 404
The closest source for Pico (the editor for the Pine email program, hence the name - PIne COmposer) should be the official site, but it’s been abandonware for a long time, as long as the university that created it forgot about it.
Not only it hasn’t been updated for MS-DOS since 1997, it depends on installing the DJGPP libraries. That makes two blasts from the past…
As for the FSF clone, GNU Nano, it doesn’t have a binary file for Windows, and the most popular independent build requires installing the Cygwin library to simulate a POSIX environment in Windows; that’s a little too heavy for what I’m looking for.
Micro
However, another clone of Pico, called Micro, can be a good bet:
It’s very young and still under development, it’s written in Go and has versions for OSX, Free/Open/Net BSD, Linux (x86, x64 and ARM), and Windows (x86 e x64)
It works well, has a command bar (Ctrl-E
) and the shortcuts are based on the Ctrl
key, following the standard of Pico, Nano, etc.
And just as we want for this challenge, the “installer” is just a ZIP with a statically-linked executable.
Installing
|
|
Micro’s config file is at $ENV:UserProfile\.config\micro\settings.json
VIM
VIM’s Microsoft build (Vi, IMproved) comes in several flavours (including a version with graphical interface called gvim
), but what matters to us is the executable for console, which is built for x86 - but we’re not about to open files larger than 2GB, right?
In case you really do need to open files with more than 2GB, Neovim is built as x64 and can be installed basically the same way as follows.
Installing
The process of downloading and “installing” is very similar to what was used for Micro:
|
|
Vim’s profile is at $ENV:UserProfile\.vimrc
.
You can check my proposal for a .vimrc
on the DotFiles page on this site.
JOE (Joe’s Own Editor)
JOE is less well-known, but has its fans.
For more information about Joe for Windows, check this page.
Fortunately, it’s available as an independent executable, and even in multiple versions depending on the preferred interface:
- joe for those who respect the classics
- jmacs for those who like EMACS
- jstar for who would rather have Wordstar
- jpico for those who miss Pico/Nano and don’t fancy hand-editing a JSON configuration like what Micro uses
Unfortunately, since they’re served from SourceForge, I couldn’t find any direct link for downloading the files in a Windows Server Core-based installation.
On a WinServer with Desktop Experience, a full browser could be used for this; but on a Windows Server Core, we have to install WGET
WGET for Windows
The Invoke-WebRequest
cmdlet on Windows Server Core can’t resort to the system’s HTML engine (Trident ou Blink) for complex HTTP requests, like these SourceForge addresses which include redirects. But a command line utility that can do it is GNU WGET, which a kind soul builds and distributes for Windows
We install WGET with the same basic method:
|
|
wget
, by default, is an Alias for Invoke-WebRequest
, so we need to call the WGET executable with wget.exe
or delete the Alias; in PowerShell 6+ it’s easy because there a Remove-Alias
cmdlet, but in Windows PowerShell (the default version on Windows, basically PowerShell 5.1), it’s a bit more complex because that cmdlet doesn’t existe and the Alias have several PowerShell Scopes. However,
while (Test-Path Alias:wget) {Remove-Item Alias:wget}
takes care of everything.
wget.exe -h
, or wget -h
if you’ve done the above:
Download JOE with WGET and install it
|
|
As you can see, Joe opens a new window instead of using the current window, so it needs to be tested if it will work in a pure remote shell like SSH or PSRemoting; this RDC session isn’t enough.
Testing with OpenSSH
On Windows Server (2022 ou 2019), run the command:
|
|
Name : OpenSSH.Client\~\~\~\~0.0.1.0 State : Installed Name : OpenSSH.Server\~\~\~\~0.0.1.0 State : NotPresent
The SSH client is installed, so we install the OpenSSH.Server following Microsoft’s instructions:
|
|
As we already have the SSH client installed, we can open an SSH session directly in the localhost
:
|
|
The authenticity of host 'localhost (::1)' can't be established. ECDSA key fingerprint is SHA256:[…]. Are you sure you want to continue connecting (yes/no/[fingerprint])? yes Warning: Permanently added 'localhost' (ECDSA) to the list of known hosts. Administrator@localhost's password: Microsoft Windows [Version 10.0.20348.350] (c) Microsoft Corporation. All rights reserved. administrator@WIN-L32NQRNJ5GI C:\Users\Administrator>
And as I suspected, trying to open joe
on a pure CLI session, fails.
So, since to use Joe it’s required to be in a Remote Desktop session, in my opinion it’s better to just use Notepad++
As for YEdit, Micro and Vim, they open correctly inside the SSH session.
EMACS
If you really want to use EMACS to edit text files, may I suggest JOE with EMACS interface (jmacs
)?
No?
Then the best page I found that can help you is here.
Quoting the original article,
Emacs.exe binary is whopping 83 MB in size and the zip file contains two of them just in case. Whole unpacked folder is 400 MB.
I said that I was looking for small and practical solutions, not for an operating system and programming language that happens to include a text editor ¯\(ツ)/¯
Honorable mentions
The original article included many more editors, but I tried most of them and I ended up abandoning almost every one because they were impractical or incompatible.
Of those who seemed possible and which I tested, I’ll just comment on my impressions after installing them; and since I don’t find them useful for today’s environments (for example, because they don’t support UTF-8), I won’t document their installation.
Open Watcom VI
https://github.com/open-watcom/open-watcom-v2
https://github.com/tenox7/ntutils/tree/master/owvi
The author of the original article went to the trouble of compiling just the editor of the OpenWatcom IDE, and that can be installed from https://github.com/tenox7/ntutils/blob/master/owvi/vi-x64.exe or https://github.com/tenox7/ntutils/blob/master/owvi/vi-x86.exe; the documentation is at https://github.com/tenox7/ntutils/blob/master/owvi/vi.pdf
However, although it seems a good compromise between VI e a menu-based editor (it can be used just like VI, seems to support .vimrc
, but has menus), it doesn’t support UTF-8.
Kinesics Text Editor
https://turtlewar.org/projects/editor/
https://turtlewar.org/projects/editor/kit-153-win.exe
Works on multiple platforms, but the Windows installer only works with administrator permissions, which immediately warns us that it is a program from another time…
It is extremely configurable, has advanced features such as selection in column mode (VI visual mode) but also doesn’t support UTF-8
And it hasn’t been updated since 2015.
FTE Editor
http://fte.sourceforge.net/
https://github.com/tenox7/ntutils/tree/master/fte
Won’t run because it needs very old MSVC libraries that aren’t available on a modern Windows system.
Thomson-Davis Editor - TDE
http://adoxa.altervista.org/tde/
https://github.com/tenox7/ntutils/tree/master/tde
The depth of the menus and shortcuts is enormous, it’s an extremely powerful editor, but it also does not support UTF-8…
Final thoughts
After decades promoting system management by GUI, the native CLI editors on Microsoft platforms withered away until they became dead men walking. The last viable one is YEdit, maybe because its programmer hasn’t given up yet (and he seems one hell of a programmer); and YEdit is pretty simple.
But even the amazing Yori CLI utilities package wouldn’t have been successful where Cscript and Kermit weren’t (this Kermit was a port of Korn shell for Windows that Microsoft once considered developing), because the problem was that the CLI had no consistent interfaces with which to interact on a system that is wholly dependent on interfaces like Windows; this only came about with PowerShell and the ideas behind it.
The best options end up being the editors from *NIX that have remained updated and that have versions for Windows.
If the lack of support for UTF-8 isn’t a problem, I really liked OpenWatcom VI and TDE.
But my choices are clearly YEdit for quick fixes and Vim for bigger jobs.
Good luck!