Editing files in a Windows PowerShell console with vim
One of things I like about using Linux is that I can quickly edit files in the shell with vi. Say what you will about the user experience of vi (yeah okay its clunky as hell and impossible to save/close) but it generally gets the job done. In the Windows console, there is no native method to directly edit (and I mean type not write text via Add-Content) a file without leaving the shell, whether that be cmd or PowerShell. Sure, you can do “notepad textfile.txt” and notepad will open in the GUI, but that’s lame as hell.
With PowerShell Core on Linux and Mac, you can simple use vi while in PowerShell, which is fantastic and seems to work just like it would be bash.
For those of you who dare, you can install vim (just an updated version of vi) on Windows and it will just like it does on Linux or Mac.
To do it with Chocolatey (because thats really the only way you should be installing software IMO) just run this:
PS C:\> choco install vim -y
Now, I can edit files right in PowerShell:
PS C:\temp> vim what.txt
choco install nano?
Is more friendly, imho.
To each is own!
Thanks for sharing this.
In addition to your post I just watched a video about Vim Basics in 8 Minutes.
https://www.youtube.com/watch?v=ggSyF1SVFr4
Have a nice day Dan!
If you’re going to be installing Vim on a machine anyway, you might want to look at NeoVim instead.
Vim can be very powerful, but to get the full use of it you need to configure it with a configuration file – which can be a pretty daunting task. NeoVim comes installed with a lot of the most useful features unlocked by default while also being compatible with a classic Vim config file.
Beginners beware though! Vim and NeoVim both, need you to understand the concept of modes, it’s not just open and edit.
Cool! I will check that out.