PowerShell + VI

By: George Rolston

I have been a long-time PowerShell advocate enjoying its command-line and scripting experience similar to my experience within a Linux environment. However, there has always been one shortcoming of the PowerShell console: no console-based text editor. I found it to be extremely annoying when wanting to make simple configuration changes to a host or configuration file that really did not warrant me opening up another window to clutter my screen. Additionally, I was always frustrated when it came to opening files with notepad that required admin privileges. I always seemed to forget the requirement and after editing I would try to save and get denied. I suppose I could call notepad from PowerShell, but then I would have another open window to contend with and leave open. This destroys my maxim that all good engineers should define their work in code and should not rely on a mouse to click-about.

Therefore, why can’t we have the beauty of vi/vim or even the stupid simplicity of nano. If I had that, I would not need to worry about a mouse and could do all work with a simple PowerShell session. If you are thinking “why not PowerShell ISE or VS Code?”, well that is not really what I am discussing here. Though those two are excellent code editors and I highly recommend any IT engineer to become familiar with them. What I am discussing is being able to make edits of a document interactively through the command-line.

Searching through the internet I finally stumbled upon a great write up on leveraging gvim and setting it up to work with PowerShell (ref: Much to my delight it worked out great:

Within one window I can create a directory then call vi with a new file name to easily start me on my way to building docker images!

With a simple :wq! my file is created and I am back at the console and ready to run my docker build command without need to click-about or wonder which screen/window to look at thus most likely getting completely sidetracked. Simplicity is divine and this is nirvana.

I was in love with the setup so much I wanted to bring it to every windows system I had to use. However, the setup was a lot of steps and I am sure I could not do it consistently if you paid me…plus it involved a lot of clicking-about; therefore, I setup a quick one-liner anyone can call from PowerShell to install without having to think about all the little configuration details. Check out the project here:

When running the following in PowerShell make certain you’re running it with elevated privileges:
iex (New-Object Net.WebClient).DownloadString(‘′)


© JHC Technology, Inc.
DUNS: 961809790 | CAGE Code: 5YRC8 | NAICS Codes: 423430, 518210, 541511, 541512, 541513, 541519, 541990