Friday, September 30, 2022

Vim and Windows? YES!Vim and Windows? YES!


# Installing vim-console on Windows 2022 from PowerShell
Working with Windows Containers has provided me tremendous education.  Learning PowerShell has shown me how far the windows realm has come in the form of CLI management.  It still seems to be lacking in a few areas, and I really don't like the extremely verbose syntax nor the single dash arguments.  But I digress.  This post is about solving a single problem.  The one problem with endless obtuse workarounds.

## Problem
Editing text files...from a windows CLI (cmd.exe, PowerShell, etc).   

## Solution
Find the Microsoft equivalent of Vim.   Is that Notepad.exe?  Wordpad.exe?  Get-Contents?   
Fail, Fail, Mostly-Fail

## My Solution
Install vim-console; an extremely powerful text editor that has proven to be the staple of all *nix users around the world for decades.

Note: There are many articles similar to[How to Edit Files with a Real PowerShell Text Editor](https://adamtheautomator.com/powershell-text-editor/) that show how to use Chocolaty to install Vim, Emacs or Nano.  However, most of my use cases don't allow Chocolaty in their datacenters.   So, we have to install vim the hard way.

### Steps.
1) SSH to your server.   
Don't know how to setup ssh on Windows?  I will point you at their documentation 
    - [Getting Started OpenSSH for Windows](https://learn.microsoft.com/en-us/windows-server/administration/openssh/openssh_install_firstuse?tabs=powershell)
2) Verify you are in PowerShell 
    Type the command powershell or pwsh and hit enter
        image
    Look for the PS in front of your command prompt.
        image
3) Download vim-console artifacts [NLUUG - dunno where I found this](https://ftp.nluug.nl/pub/vim/pc/)
    - wget https://ftp.nluug.nl/pub/vim/pc/vim90rt.zip -o vim90rt.zip
    - wget https://ftp.nluug.nl/pub/vim/pc/vim90w32.zip -o vim90w32.zip
4) Extract archives
    - expand-archive .\vim90w32.zip -DestinationPath .
    - expand-archive  -Force .\vim90rt.zip -DestinationPath .
5) Run installer
    - cd vim\vim90
    - run .\install.exe
    - Change settings as needed and say `d` for do it
        image

6) Run and Profit
    - Simply type `vim` and hit enter
    - To exit the key sequence `Esc-:-q-` will exit.   

## Conclusion
I didn't go into a lot of detail but hopefully this helps with the steps for using VIM.   

-Nate

No comments:

Post a Comment

Adding nerdctl to an OpenShift 4 Windows Node

# Getting a Windows Node on OpenShift ... Not what this post is about, follow the Red Hat and Microsoft documentation and then consult with...