Thursday, 4 February 2016

Understanding VIM

Me and Vim have a complex relationship. I spent a lot of time loathing it, a small amount of time putting up with it and now all my time using it.

I was born in the late 80's. I grew up with graphic user interfaces, this was a good thing, it was easy to pick up and play with. I didn't have to worry about permissions,  .swp files and the like. I could use my mouse to highlight all the text, click where I wanted to start typing and just start typing.

Then when I got older and started using Linux I took my first step into the world of real programming, no more batch files for me!
I was told that Vim was an incredibly useful tool you could use to write code, I tried it, it did not make me happy.

"Why do you have to press 'i' every time you want to type?" I asked myself shortly after discarding it and using a more notepad-esque option.
I read that the reason for this is so you can execute useful commands such as a search and replace:


"How is this better than CTRL+F?" I thought. My general opinion was that Vim was needlessly complicated and so I forgot about it.

After university I got a job at a company which provided Real Time information for buses. Each bus stop had a digital display which received information via GPS or Wifi. One of my jobs was to remotely access these digital displays and update the software within. The problem was that each display ran a headless version of Linux called TinyCore, this means it had no GUI. I watch a few of my colleagues editing config files using Vi or Vim and decided to give the editor another go (not that I had any choice). I learned a few basic commands and I got used to it, but I still didn't like it much.

Things stayed that way for a while, It's only been the last few years that I have realized what I have been missing with Vim.

I have downloaded Vim Improved text editor which I now use daily, hourly almost. The great thing about it is that it you learn the command line vim by using it. when you click file it gives you all the usual options, i.e. Open, Save etc, but just on the right it shows you the relevant command to preform that action on the command line.

Currently I do a lot of work on a Linux server running redhat. With Vim I can, remove duplicate records just by typing:

:sort u

I can column select by pressing 'SHIFT+V' or 'CTRL+V' and then select my column, then by pressing 'I' and typeing what I need, then pressing 'ESC' all rows have been updated.

I have misjudged Vim and i am now spending a lot of my time realizing how great this software actually is.