Macha
Vim
On the advice of Sirupsen, I have been trying out vim during the last few weeks. Up until now, my editor of choice has been gedit on Linux, or Notepad++ on Windows for most stuff. I have also used VS on Windows, which while good for C#, it doesn't really help writing multi-platform programs. And I've used Eclipse a bit, back when I used Java for a while. But, most of my programming is done in languages such as Python, PHP and Javascript, and for the small size of my projects, IDEs tend to get in the way, and they also aren't quite as good for dynamically typed languages anyway.
So first of all, to quote one of my tweets:
After using it a while, I apologise to vim users. It isn't weird and crap, it's just weird.
I haven't exactly been the most positive of vim. After all, as a Linux user, it's nigh impossible to use many of them without one of them using vim or a vim-like interface for something. And while nano manages to be relatively easy to understand, vim does not. Because vim is weird.
But after a while of using it, I realise it's weird for a reason. Want to get rid of a line? In other text editors it's:
- Left arrow to start of line
- Hold shift
- Hold right arrow to end of line
- Press delete
In vim it's:
- Type dd
Don't like that 13 line function anymore, and want to delete it?
In normal editors it's:
- Up and left arrows to start of function
- Hold shift
- Down and right arrows to end of function
Vim is:
- Type 13dd
Weird, obtuse, but once you learn it, it's far more efficient. A final example. Suppose you want to rename that variable from $car to $vehicle:
A normal text editor?
- Edit
- Search and Replace (somethings this is part of search anyway and under Ctrl-F, other times it's its own menu, under Ctrl-H)
- Type in $car.
- Type in $vehicle
Vim?
- Type :%s/$car/$vehicle/
At this stage, I'm still not getting the most out of vim. After all, I only know a few basic commands (and even then I'm missing a few. Any vim users care to tell me how to Select All?). Yet I'm already finding it easier and faster than I did in other editors. vim is also cross platform, unlike the Windows-only Notepad++ and Linux-only gedit, which means I can use the one editor across all OSes. For that matter, it's even available on my jailbroken iPod touch.
Another useful feature of it is it's huge styling and plugin community. Again, Sirupsen pointed me to BusyBee. I didn't quite like that, so I found Mustang, the theme it was based on. I haven't yet found plugins that I'd reccomend, but the choice is huge. One of the inbuilt ones, allows you to set different options per language. I'm doing a project in Ruby atm, and in any other editor I'd have to change my settings to and from my personal preference of tabs and Ruby style of double spaces. With vim, I can set it to do tabs with all other files, and just do the silly double space thing with Ruby.