So today's post begins with a question: what editor is your favourite? Do you have separate editors based on different contexts (eg. Netbeans for Java, Dreamweaver for sites), or do you tend to stick to a single Man Friday to fulfill all your needs? Do you prefer IDEs or simple text editors?

My answer for the above questions:

I love gVIM (graphical VIM). I've set it up to work over SSH in Windows (I work on a different box and merely use my laptop as a convenient interface), hidden all menu bars and installed a colour theme pack of which I'm currently using "Evening". And I've started using VIM for every code related task I do. In defence of my choice, allow me to introduce some of the basic functionality included in VIM and some practical use cases: (Not intended as a tutorial, but a quick glimpse at the great functionality on offer)

  1. Simple Editing
    Typographical errors are the programmer's bane. And if they're not shown as errors (occasionally the case with various Javascript libraries), life becomes hell. Quick correction options in vim:

    • dw, dd, etc. Basically, both for deleting and cutting text. dw deletes till the end of the line. d2w deletes 2 words. dd deletes the current line. Entering %d on the command line (i.e. using : ) deletes the full file. D deletes until the end of the current line. Considering standard equivalents, I'm always astonished by what I can accomplish so quickly in VIM.
      I really tend to use d...d to quickly get rid of large chunks of commented code. Or simply for moving code around very very quickly.
    • r, rw, etc. d was for delete. r is for replace. Need I elaborate?
      I tend to mis-type certain words a lot. Really easy for me to just go over the offending character and type in rx, where x is the new character I want to replace it by.
    • o, i, a, A, etc. Single keypresses for: 0: add a new line after current one and start editing, O: add a new line before the current line and start editing, a: start appending after cursor, i: start inserting before cursor, A: insert stuff at end of the current line.
      A is the forgetful programmer's boon. Really useful for adding ; at the end of lines.
  2. Editing over scp/ftp/etc.
    Vim comes with a special plugin (NetRW) that lets you quickly edit files over your protocol of choice. I regularly use
    :e scp://<username>@<host>/path/
    to get a directory listing of all the files in that path; choose your file and edit away.
  3. Search and replace
    Ever changed a variable at the last minute and had to change it? Easily carry out regular expressions over very simply defined yet complex range of lines using /<pattern>/ or :s/<pattern>/<substitute>/flags. You can even carry out commands on matching portions. One of the most useful features I've used once I got the hang of it.
  4. Ranges
    Vim's flexibility in terms of defining ranges for substitution/deletion/anything you'd care to mention is amazing. One of the features I most constantly use is 'marks' that allow you to mark certain positions to be easily referenced later.
  5. Too many colour themes
    The amount of possible colour themes available is astonishing. And allows a UI freak like me to be completely satisfied with what I'm coding in. And switching quickly when I want to.
  6. Registers
    Registers allow you to cut/copy and store stuff in different named "registers and then paste where and when you want. Anyone who's shuffled through various files can easily comprehend the huge help this is.
  7. Buffers and Tabs
    Tabs are essential to any decent program today. Buffers are tabs without the graphical interface indicating their presence. The best part is while using Vim in linux I tend to use
    gVIM -p *.php
    and other such commands to quickly open all files of  a single type in tabs in a single window. Really makes finding the right file much much easier.
  8. Sessions
    Using :mksession and :source allow you to quickly open all the files you had open the last time you sat down to work. And as you get to choose where the file containing the session is saved, handling sessions becomes really simple and easy.
  9. Abbreviations
    How many times do you find yourself using common stuff like console.log() or error_log() while debugging? Just use the command
    :ab cl console.log
    and every time you type cl( (followed by a space/newline/./(/etc.) it will be automatically expanded. I imagine you can see the possibilities. Interestingly, abbreviations can be saved in sessions so if you don't want to keep an abbr. around for a long time, or have something specific (such as a class name) just use and save it in the session.
  10. Key Mapping
    Map keys to carry out your most often used commands.
  11. An awesome community
    There are thousands of sites out there with pointers on using VIM as well as an excellent Vim tips twiki. Be sure to check out the VIM tips twiki and this presentation on VIM for PHP programmers by Andrei Zmievski to get a much better idea of what VIM is capable of.

Also, for those of you who edit a lot of stuff on the web (using text boxes), install It's all text to edit any text box's contents using your favourite editor (VIM, anyone?). This post was written in gVIM, opened via "It's all text" on the excellent blogging platform provided by Wordpress.

Editors for coding?

I seem to have developed a habit of blogging on Saturdays. Interesting.

So today wasn't a bad day; attended a nice series of talks by the heads of Naukri.com and Rediff.com as well as a very interesting presentation on current internet trends -- as well as what had been predicted by a certain investment company a few years in the past, and how well those predictions stood up to the test of time.

I also got myself a new book -- Nightfall/Asimov. At this rate, I might set up my own library in Blr before leaving.

Tomorrow will be spent in office; working a bit, practicing pool shots in the recreation room and maybe even gymming if the gym is open.

Today will be spent in going to the mall, having a spot of dinner followed by doughnuts(!) and probably ice coffee. Maybe even practicing the guitar a bit.