Tuesday 4 January 2011

Vim..a n00b's experience

Vim is an improved version of the Vi text editor which has been kicking around since 1976. After some initial scepticism I've found that is an incredibly powerful and useful tool. I'm just learning but all ready feel that my productivity is increasing.


Why Vim?

I never thought I'd feel excited enough about a text editor that I pony up the cash to pay for it. After all its just a text editor right? Well that's what I thought until I found Textmate for my Mac. This seemed to bring a whole slew of new features that made coding faster and easier. I'm sure that I wasn't even using a fraction of the available abilities. Then I moved to Linux and found gEdit which is just a plain old text editor. Now I spend a lot of time at work ssh-ing to unix boxes and if I need to view or edit a file my choices are limited. The commands used in less and more, translate to Vim so I needed to learn about more (bad pun intended) about it. I found that once you've learned relatively few commands you can navigate round a file in no time. I decided to see if Vim could be useful as my default editor at home as well. The Vim website has binaries available for installing gVim (a Gui based version) for Linux, Mac and PC so I didn't have to code inside a terminal window. I also downloaded an excellent 4 part video tutorial from Net Tut's called Venturing into Vim by Jeffrey Way. This series was very useful in explaining the basics (and some advanced stuff). If you're wanting to learn more I'd highly recommend this series.

So what's so cool about it?

When I work I prefer to have my hands on the keyboard as much as I can. I don't like to be continually moving my hand off to grab the mouse. Vim lets me not only insert and edit text but also to navigate without having to wave my arm around. This translates to faster input. Once you're familiar with the Vim way, most commands are intuitive and seem to be the logical way to do things. Even though its text based you can still use tabs or split the screen vertically or horizontally (and multiple times). You can carve up your workspace to make it however you want. Check out this screenshot.  I defy you to do that in your vanilla flavoured editor.
This is just one of the many flexible things you can do with Vim. Its not an IDE but its totally lightweight and can support syntax highlighting.

The trick with Vim is that it is like a language all on its own. Once you've become familiar with it, it will quickly become second nature. Part of the curve is that Vim has a number of different modes: command, insert and visual. Depending on what mode you're in, keystrokes will mean different things. For example, in command mode [shift] + g will move you to the end of the document, while in insert mode it will give you a capital G. By default you start in command mode and you choose to enter text by one of the many insert commands. For example i to insert before the cursor, o to insert on the next line, a to insert after the cursor, A to insert at the end of the line. The options are plentiful. Do a quick google and you'll find any number of cheatsheets and shortcut lists available for Vim so I'll not repeat them here. The thing to remember is that once you've finished in insert mode hit [esc] to go back to command mode. This is a lesson that's learned from experience as I seemed to finish my text files with :w!

You can change the colour scheme from the plain black and white to a number of provided colourful schemes. I'm using the quite dark "ron" scheme at the moment. If you want to set a scheme to load by default you can add a .vimrc file to your home directory. This can be used to customise your Vim with all sorts of things, such as line numbering, syntax highlighting (I've tested it with Java, Groovy and HTML) and auto indenting.

I'll post more about Vim as I learn but so far I'm thinking that if you can type Vim might be the editor for you.

Monday 3 January 2011

Samsung NF210 Netbook Opinion

For Christmas 2010, we got my youngest daughter Em a Samsung NF210 netbook. She's a budding nerd and has been hacking away on some Python scripts and I really enjoy working on this together with her. She had previously been using a hand me down Powerbook but its best days are now long gone. I didn't want to spend a bucket of cash and she liked the funky shape of this particular model (girls really!!).

The hardware
This Sammy comes with a 1.66 GHz Atom process, 1 GB RAM and 250 GB hard drive. I'm not sure of the weight but it seems much much lighter than my Macbook. The screen is bright and battery life is quoted as up to 14 hours. Even taking out the usual marketing spin the battery life is awesome. Anything better than 8 hours is dynamite IMHO. In addition there's a built in web cam which is unnecessary for me but Em thinks its pretty cool.

The software
Ok so here's a bit of a negative, the shipped OS is Windows 7... Starter!! I had to hide my natural bias and told Em we'd see how it worked out. Em was excited because she'd be able to run all those programs that she couldn't run on the Mac. In actual fact, there really wasn't anything in this category aside from ridiculous smileys and other .exe malware. Em was disappointed that one of the unnecessary features removed from the Starter edition was the ability to change desktop backgrounds.
So within 24 hours, Win 7 Starter was gone and Linux had been installed. We tried a bunch of different flavours, Meego, Moblin, Smeegol, Mint (XCFE), Ubuntu UNR. Meego and Moblin in particular have a beautiful interfaces for portable devices. Initially I couldn't get wifi working as the netbook uses proprietary Broadcom drivers (although I'm told these are now open). After much mucking around I finally got the drivers installed and it worked really well. I'd have to say that one of the big pluses for Meego is the community. It took a long time to get the wifi problem sorted but there were people willing to help on IRQ and twitter. (Particular thanks here to Andy Bleaden @andybleaden for his assistance). However I needed to get VLC working before the young one goes away to grandma's house and this involved a whole new round of pain. We've settled on Ubuntu UNR as the best fit between usability and functionality at the moment. I'm not particularly keen on the Unity interface and we'll sure have another look at Meego in the future.
Ubuntu runs well but so far we've not found a solution for the non functioning brightness keyboard controls and the annoying trackpad which moves the cursor when bumped while typing. I'm sure there's a fix out there for that one somewhere though.

The Verdict
Its terrific and I want one. The screen is small but perfectly usable for web surfing on knocking up a script or two. While its no desktop replacement its perfect if you're on the road or want to have web access with you wherever you are. I've not used an iPad but can't see why you'd want an iPad when you could get one of these for so much more bang for your buck.