Why Did I Stop Using Vim?

They say once you use Vim, you never go back.

Agrover112
CodeX
7 min readJul 17, 2023

--

As a developer, using Vim can be quite threatening. Especially if your peers force you to use Vim, or subtly hint every time at using Vim. It feels like a bit like being Neo from The Matrix, going about your usual unsuspecting day and then appears a glitch in the matrix:

“Have you tried Vim before?”

Woah, a glitch in the matrix

This is your last chance. After this, there is no turning back. You take the blue pill — the story ends, you wake up in your bed and believe GUI is power. You take the red pill — you stay in Wonderland, and I show you how deep the wonder of Vim goes. Remember, all I’m offering is the truth — nothing more.

Red Pill or the Blue Pill?

Chose the red pill to proceed or stop? Click on the image .

Source: Google Images
Source: Google Images

Consuming the Red Pill

Well, like many of us I chose the Red Pill. As a developer, most of you must have heard of various Vim jokes about how difficult it is to exit Vim, along with the steep learning curve associated with using it.

Source:@iamdevloper Twitter

Contrary to this popular belief there are many reasons to use Vim. If you are the type of coder who lives and breathes in the terminal and could easily do without the GUI altogether, then Vim is an excellent choice for an editor.

One of the clear advantages of using Vim is its usability when SSHed into remote servers. In such scenarios, it may not be convenient to use VSCode, as it would take only a couple of seconds to type “vim” and start editing, rather than dealing with potential issues like VSCode updates that crash or conflicts with extensions, requiring time-consuming debugging and repetition. Additionally, considering that VSCode is owned by Microsoft, an open-source but potentially vulnerable to security breaches, or could face disruptions due to geopolitical events such as sanctions or conflicts, the risk involved in relying solely on it may not be worthwhile. On the other hand, Vim has a long-standing legacy as an editor and is likely to remain relevant even 20–30 years from now.

Understanding Vim

Vim isn’t magic. It’s made for the programmer in mind.

As I delve deeper into the mysteries of Vim, I started developing an understanding of Vim.I simplify how vim works in the form of this diagram.

For the more advanced readers one can understand this as a Finite State Machine(FSM) but for sake of simplicity I will refer to it as a graph.

Source: StackOverflow Vi editor as a Finite State Machine

From the above graph it’s quite clear how you enter the command then pressing i enters you to the insert mode. Then pressing ESC back to the initial node.Now again pressing : you enter a different mode and press w and the changes are committed.

You can think of it a bit as how Git works where after a combination of git add and git commit the changes are moved from the staging area to local repository.

An important collection of VIM Commands

# Note '/' means or 
# ':command' are Ex commands whereas rest are key-presses.
# Initially 'Press' be specfied but for rest of the commands it will be ommitted
# so as to only initially make the reader comfortable.
# Quit
:q!
# Write and quit
:wq
# Undo last change
Press u


# Set Line Numbers
: set number
#Remove Line Numbers
:set no number



#Change text inside () {} [] '' opening and closing braces
Press ci(/{/[



# Move to Start of the Line
Press _
# Move to End of the Line
Press $

# Move curosr Up/Down
j/k
# Move cursor 10 lines Up/Down
10j/10k

# Move curosr Left/Right
h/l
# Move cursor 10 char Left/Right
10h/10l




# Move to Start of File
:1
#OR
Press gg

# Move to End of File
:$
#OR
Press G


# Create a vertical/horizontal split of 2 files
vim -o/O file1 file2
# Create an empty horizontal/vertical split
:split/vpslit -
# Open an file in an empty split
:edit PATH/file1
# Split the same file horizontally/vertically
:split/hsplit #OR
CTRL + S / CTRL + V

# Move between file splits
CTRL+W , → ↑←↓#and Direction or h/j/k/l
# Increase or decrease Split Height
CTRL +/-


# Delete word
:dw
# Delete 2 words
:d2w
# Delete entire line
:dd
# Delete 3 lines
:3dd
# Delete till a character 'a'
:dta
# Delete from a character 'a'
:dfa

# Copy and paste
y/p




# Search
:/pattern
#Search with highlighting
/pattern


# Open New Empty Tab in Vim
:tabnew
# Open Tab with given File
:tabe PATH/file

# Close a Tab
:tabclose / CTRL +W , c

# Switching between Tabs
# Go to next tab
: gt
# Go to previous Tab.
: gT
# Switch to 1st/2nd/nth Tab.
:tabn 1/2/3
# Switch to First/Last Tab.
:tabfirst/tablast

Both Pills?

After being on the Red Pill for quite a long time you start missing something? Despite the intuitive key bindings, Vim still felt quite empty to me. I decided to experiment with Plugins such as NERDTree, VimBundle, Plug , fzf , NeoVim , etc.But even after so much customization and pretending to be an elitist I just felt a wierd hollowness or emptyness so to speak.

Source: The Matrix Wiki

What is missing here? I asked the Oracle.

“ You miss an feeling, a feeling you cannot replicate. Stop fooling yourself for the road lies in both where you are but also where you have already been. ”

It was then I realised I was in denial over the fact that I loved a visual way to program. Visual explanations, visual representations always helped. From visually looking at Git conflicts, or diffs to line highlighting, code highlighting and everything else.

Being accustomed to programming using Java on BlueJ since I was a kid , I have come to realize the importance of graphical aspect in programming. Despite the perception of being a Vim elitist I firmly believe that programming is a diverse field catering to different learning and thinking styles. People possess varying preferences, with some being more inclined towards visual, auditory, or mathematical approaches.

For if GUI based editors had no usability then we would not have various Plugins, Visual Icons, Material Design Themed Icons, fzf, etc to Vim. Vim would be a lot more simpler like our Terminal. There would be no Jupytr Notebooks if simply the Python REPL was so good to use,there would be no need for a PyPI website or Git Kraken . Ironically speaking the concept of Vim itself uses a visual mathematical paradigm in the form of FSM which are closely related to a class of Graphical Models. Visual and mathematical ideologies cannot be simply separated from code altogether, both go hand in hand.

There is a middle ground that has worked well for me: utilizing VS Code with Vim key-bindings. This setup allows me to combine the speed and efficiency of Vim key-bindings when necessary, while still benefiting from the visual support and guidance provided by Visual Studio Code. It’s the best of both worlds, enabling me to work quickly with Vim shortcuts and seamlessly switch to using the mouse or taking advantage of the rich features and interface of VS Code. I wonder how many folks out there that are using editors or software’s such as Vim just to appear elitist despite hating the tool.

Closing Thoughts

In conclusion, my journey with Vim has been akin to taking a Red Pill from the matrix of conventional programming environments. While Vim initially captivated me with its efficiency and powerful command-line interface, I soon recognized the value of striking a balance. The graphical aspect of programming cannot be disregarded, as it caters to the diverse learning styles and preferences of individuals. Whether one leans towards visual, auditory, or mathematical purist approaches, finding a middle ground becomes essential. Embracing tools like VS Code with Vim key-bindings has allowed me to harness the best of both worlds, empowering me to work swiftly with familiar shortcuts while benefiting from the rich visual support and features of a modern IDE. So, let us remember that in our quest for programming mastery, it is the harmony of efficiency and accessibility that truly sets us apart.

Resources

Before you leave feel free to connect with me on Twitter as @agrover112

Join my email list for more memeworthy helpful tips!

--

--

Agrover112
CodeX

Tech enthusiast sharing insights on coding, education, and personal growth. Explore my blog to learn from my experiences and find new ideas in the world.