Windows Nano (not server)


If someone put a gun to my head and asked for a list of three favourite Microsoft products, it would look like this: Visual Studio Code, PowerShell and Windows Terminal.

Windows Terminal is the youngest kid on the block, but it’s getting more mature with each release. I especially love its low footprint — I have never seen it to go beyond 30 MBs of RAM. As it’s now possible to manage Windows using just a command line, there’s a chance you’ll be spending more and more time using this tool.

When working in a text-only environment, you sometimes need to view or modify a file. How do you do it without leaving the terminal? edit is not available in 64-bit editions of Windows, you can, of course, use Notepad, Notepad++ or VSCode but these are desktop apps, launching in separate windows and if you live in the command line, you want to avoid leaving it unless you absolutely need to.

Nano to the rescue. It’s a simple but compelling text editor for Unix-like OSes which, fortunately, has a Windows port. If you use git, you already have nano present on your disk, just add <your git installation path>\usr\bin to your PATH and you are all set.1 It takes maybe a fraction of a second to start the editor!

I know, Vim is better but :wq, really? 😊

Now, everything works, you can just do nano somefile, and you have a very nice command line editor at your fingertips. The only missing thing is code highlighting.

If you work with PowerShell a lot, like I do, and you use git, all you have to do is:

$gitpath = "C:\Program Files\git" # this path can be different, check before executing
 (Invoke-WebRequest -Uri https://raw.githubusercontent.com/scopatz/nanorc/master/powershell.nanorc).Content | Out-File "$gitpath\usr\share\nano\powershell.nanorc"

If you use a standalone version of nano, you will have to do this:

(Invoke-WebRequest -Uri https://raw.githubusercontent.com/scopatz/nanorc/master/powershell.nanorc).Content | Out-File "~/.nanorc" -Append

Nano’s code highlighting is a far cry from what VSCode can do, but it’s good enough and, again, you will use it just for quick edits.

Take a look:

alt

More syntax highlighting definitions can be found here.

That’s it for today. Nothing fancy, just pretty useful. Me, personally? I cannot live without nano anymore.

  1. There is also another source of nano for Windows but I like the git version better.