I recently switched over to Ubuntu as my primary operating system on my laptop. It's been a long time coming considering that I'm a Computer Science student with a heavy C oriented course load. However, it's not just the operating system that matters when you're writing code. You also have to decide what you're going to write your code in. Some opt for an IDE like eclipse, while others keep it simple with nano or gedit. As with almost all other things in life, it's important to find a healthy medium. When you're looking for something without the bloat of an IDE but with more functionality than a simple text editor, most roads will lead you to either emacs or vim. I've long considered myself an opponent of fanboyism, so, after taking 392 and listening Professor Gabarro's rants about how great emacs is and how much vim sucks, I decided that I'd start using vim. However, I've also always considered myself a hypocrite, so let me tell you about how awesome vim is!
Vim, short for vi improved, is an improved version of the classic text editor vi (go figure). Classically a modal editor, vim works in modes. When vim starts up, you start off in normal mode, which means that you can't just start typing. Now I'm sure you're thinking "what the heck is this boomshocky? why the flip can't I just type the shtuff I want to?" (edited for G rating). The answer is simple, vim allows you to navigate and manipulate text files right off the bat. Once you learn the dialect associated with vim, hopping around your text document in normal mode becomes less of a combination of shortcuts and more of a language. The best part is, all of this is available from the home row. With the proper acclimation period, a good touch typist can become more efficient with vim than they would be with a regular IDE. Now that we've gotten the awkward introduction out of the way, let's tackle some of the deeper questions associated with using vim before I allow you to touch my baby. You're almost definitely thinking, "why would I learn this antiquated method of editing if I'm already as addicted to IDEs as Ewan McGregor was to heroin in that one movie?" The answer is multifold. For one, you won't always have access to a GUI when editing code. You can't always expect to be able to edit from the comfort of your own rig. Sometimes you have to SSH into a machine to do some work. Another point is that you can really be more efficient with vim. Think about all the scrolling and clicking you'd have to do to navigate to a particular line in eclipse or a similar IDE. In vim you'd just type the ":" character and the line number. BOOM! You're at the line you wanted to be at. Another benefit of learning vim is that it's mostly POSIX compliant. Any concepts you learn to become a better vimmer basically carry over to linux operations. For instance, using a regular expression search in vim requires you to know POSIX regular expressions. Knowing vim makes you a better computer scientist.
Overall, what I'm trying to say is that every computer scientist should at least know how to use vim. It's not perfect, considering that it's really only a text editor and lacks functionality in terms of syntax highlighting and autocompletion without plugins, but I find it better for my needs than emacs. So, I'll generalize: vim is better than emacs. Prove me wrong in the comments.
http://www.webcampus.stevens.edu/uploadedImages/090_About_WebCampus/_photo/gabarro.jpg
ReplyDeleteI think I have sufficiently proved you wrong.
Try out some vim bindings when you're browsing a man page. Most the basic ones are there, including search!
ReplyDelete