Why I use Vim

by Niki on November 9, 2011

1. I can do everything with only my keyboard

All editing, copy-paste, navigation, etc are done with the keyboard. No time wasted having to grab a mouse and target GUI elements. This not only saves me a lot of time, it also reduces what I call “context switching” . In computer science a context switch is the process of storing and restoring the state of the CPU when switching from one process to another. These context switches are very expensive in terms of performance thus keeping them to a minimum is a must. The same is true for our beloved human brain. Going from doing one thing to doing another requires us to change our current state. When for example I am mistakenly coding a function¬† into the wrong file I will have to cut this code, and paste it into another file. In most text editors or IDEs I can’t do this very easily without grabbing my mouse and clicking some GUI elements, both requiring a state change from me. With Vim, being able to stay in one state while developing software, my hands on the keyboard and my eyes on the screen, avoids unnecessary context switches thus adding to my productivity.

2. Advanced text editing

Vim can do edits only dreamed of by others.¬† Cut the current line preserving a blank space? No problem, just hit D. No need to preserve a blank line? Double d will do. Want to start editing above the current line, just press O baby. Once you get the “modal thingy” your mind will be blown. Start writing after or before the current character, increment or decrement numbers, delete 3 words at once, select this whole function, make this entire line upper case, select the next 55 lines, repeat the previous edit 15 times, etc all with a few key strokes.¬† My productivity is higher because my editor’s capabilities surpass that of every other editor on the planet and because I have invested time and effort in learning those capabilities.

3. Macros

You have just received a text file with 1100 addresses in the following format:

Macaronistreet 55, 2044 brochlochem; ZC

You need these to look like this:

<street>Macaronistreet</street>
<nr>55</nr>
<zip>2044</zip>
<city>brochlochem</city>
<country>ZC</country>

no problem

Start macro recording, do the edit on one line, stop macro recording and press 1099@q

DONE. The next 1099 lines will be formatted just like the one you have edited by hand. No code to write, no script to run.

As a bonus I have included one of my favorite VIM videos on youtube. Enjoy!

 

{ 0 comments… add one now }

Leave a Comment

Next post: