Start of My Vim Journey

As I continue to work on my Senior Design Project, I have reached the point where I am now on to the “cloud” aspect of it. I am well enough into the Firmware for my devices, that I now must pivot towards implementing a way to communicate to these devices remotely. I mentioned in my intro post, that I wanted to leverage WebSockets with Golang, and given that I have very little experience in both, I figured it was a brilliant idea to kill 2 birds with one stone. So a couple of weeks ago, I came across this video from AnthonyGG:

AnthonyGG - How To Build A Chat And Data Feed With WebSockets In Golang?[1]

You could choose to watch the whole video, but only a few minutes will do to help explain my point. I was watching along and copying down the code, but I kept having to pause to catch up; he was typing way too fast. Even when turning down the playback speed; some of the movements just seemed way to fast for me to do at the same pace. I decided to see through it, and continued watching to understand the concept. Other than maybe a quick crash course on Go and its semantics, I had never really seen an application written in it. The idea of go-routines really caught my interest; I quickly realized how comparable this feature was to FreeRTOS tasks. I will be sure to talk more about that and my project soon :).

Another feature of Go, or at least of the Golang ecosystem, is the nature of the compiler to be very strict, and as such demands the minimal amount of thought to code. From my brief code-along with the video, I noticed that the code would not compile unless I got rid of unused variables. This to me was a first, and really opened my eyes as to what modern tools have become. In the other programming languages I’ve worked with, the most that would be shown in the compile or run stage is the fact that there was an unused variable. This could be common if you want to test something, to have the lines of potential variables to use; but this more aggressive approach I believe fares better for the developer. If you don’t use a variable, just remove it from the code.

Ok, too much Go talk for now, let us get back to the point of this post: Vim.

One thing I noticed while coding along with AnthonyGG, was that in the bottom of his VSCode window, there was a “NORMAL” indicator, and sometimes would change to “INSERT”. A couple of days after finishing the code (unsuccessfully working because my other clients couldn’t connect without correct Protocol Upgrades). In my free time, I looked these things up. I also asked ChatGPT, and soon enough I had my answer.

Vim: What is it and Why Even Bother?

I would say that my journey with Vim starts right here. This was the start of my research (mainly YouTube videos). I learned that Vim was a Text Editor, initially based on the Vi editor released in 1979, but what is more popular, and what I was indeed after were Vim motions. These were essentially the keybinds that you use to navigate around and edit text in the Vim editor. From my research I quickly learned that using Vim motions gives you the ability to edit text without the need for a mouse. We can get into the reasons as to why this is a great time saver, but it speaks for itself. If the goal is to have as little friction between your ideas and the program your writing, spending just a couple of seconds moving from the keyboard to the mouse is just too long. And it adds up.

Having spent the past Winter Break programming my ESP32 devices for the Senior Project, I realized there were some pain points while editing. My main gripe was that I had no way to easily highlight text between things like quotes, parentheses or brackets. Maybe I had gotten used to the friction of that, but during this time I was growing annoyed of it. And what does someone that uses VSCode do when their is a missing feature in their setup? Search for an extension!

I ended up finding an extension that allowed me to easily perform this. Although it seemed to make my movements faster, it just was not enough. Things like moving to the end of a line, the beginning of a line, moving to a closing parenthesis. Thing like this I always wanted to do; not to say that it is possible, using arrow keys could make it work. But it was just too slow. I needed something better, and I’m happy that the alternative exists.

Practice Makes Perf—Better

I could continue to watch all of the Vim videos on YouTube, but I would never get better unless I started using it. After a while, I searched for resources that would ease the process of getting accustomed to the Vim binds. The hardest of them in my opinion was the new way I was going to navigate through a piece of text: HJKL. I mean think about it, even the time it takes to move your hand to the arrow keys is just wasted time. At all moments, while using Vim, you have your hands on the center of the keyboard, always ready to type. I found a web based adventure game where you can learn new binds as you complete levels.

Vim Game
Vim Adventure game [2]

After slowly but surely getting through the levels, there comes a point where you need to buy a license to the game to continue playing. A bummer, but at the same time I decided to move on, since I was not going to be in a game all the time. So I once again did some research. I came across a Git Repo from ThePrimeagen, called vim-be-good↩, which is a series of minigames if you will, all in the terminal based editor Neovim. Since I am on windows, I decided to just try out the Docker container that is available. It bundles an installation of Neovim with the applicable plugins to make the game work. Here, I was able to get my HJKL movement more centered down, as they have an endless target practice mode, where you must move the cursor to a character to count as a “hit”.

VimBeGood Demo - InfoSec [3]

The obvious step to take from here is to get Vim motions enabled on my VSCode instance, and grind out the muscle memory.

Below is a snippet of how I have managed to modify my VSCode to help me get good at Vim. You can see on the right pane, how I added some custom settings to open and close the file explorer, among other things. Since I have my configurations synced through GitHub, I will have the same environment across my Laptop and PC at home.

VScode
VSCode Layout with Vim extension [4]

I have made a commitment to myself that I would not turn it off, no matter what. It is finally time to elevate my experience as an aspiring developer.

Neovim and What could come

As of writing this, I feel like I am enjoying this new way of editing. Navigating the file tree in the explorer using hjkl is quite nice, and I find myself relying on the mouse less and less. There are still plenty of configuration that I could do to Vim-ify my editor. There is also the possibility of ditching and Using an editor that is based on Vim, the newer and nicer Neovim. While I do feel like trying it out. I think that I must focus on my schoolwork and once I’ve graduated I will have more time to explore my options. Maybe even switching to Linux as a daily driver, who knows.

References

1 - AnthonyGG - How To Build A Chat And Data Feed With WebSockets In Golang? ↩

2 - Vim Adventures ↩

ThePrimeagen - VimBeGood ↩

3 - VimBeGood Demo - InfoSec ↩

4 - VSCode Layout with Vim extension ↩