Vim does it all
Most people think you’re some kind of freak when they hear you are using Vim as an editor. Most of the time, they end up thinking you really are a freak when they see you using it. It’s a great, full featured and simple editor. Not only it does everything all other editors do, but it does it faster and most of the time, in a more efficient way. The down side is that there is no way a single person can know it all.
Last Thursday, Yann Larrivée made a presentation about my favorite editor during the PHP Quebec monthly meeting. There were quite a few other users in the room, which made the entire presentation very amusing. Even the most advanced users and the presenter himself learned during the presentation. Quite a few people had a first look on the editor, most of them were simply stunned when they left the room. Vim is not the most simple application to learn, but it definetly is worth investing time in.
It has syntax highlight available for about every language and configuration file that ever existed. Most of them packaged by default, some available externally. The highlight is also very advanced as it can parse differently based on the context. The switch can be made manually between highlight type but the default highlight is based on the file name (for configuration files) or extension.
Most IDEs attempt to make it easy for the programmer and generate code pieces, lead you to the right places using menus. In the end, the programmer using the IDE is efficient because of all those functionalities, but the code produced is not all that clean. Using an editor like VI forces you to keep your code clean and it does improve maintainability. The editor forces the developper to use a methodology and be constant across the entire application. It might seem like a disadvantage in the first place, but when an other programmer jumps in the code, the real advantage shows up.
By using folds, Vim improves readability. Of course, multiple editors also do it, but it’s just not as good. Most of the time, they will do it using bracket matching. Vim has multiple possibilities for this task. My favorite is using fold markers. Some will complain that it adds useless characters in the code, but they are very small comments and the advantage is worth it. While common editors restrain you to folding blocks of code delimited by accolades, Vim let you define your own blocks and when folded, only the first line is displayed. It’s useful to fold methods and classes but also longer parts of procedural code or initialization phases. Code navigation is made a lot easyer.
Some like their IDE for code completition. Vim does word completition. It does not only apply on method names, but on everything. Using ctrl-n or ctrl-p will cycle through possibilities based on what’s already written. Using an additional plugin, you can even connect to your database and use completition of table and column names.
When it comes to very basic edition, it has a load of quick functionalities to replace or delete words and characters. By typing 3cw, you simply erased the 3 next words and can start typing again. The mouse is simply useless in the editor, actually, unless you use a version with a GUI, it’s not even handled. As a general idea, if you are coding, why would you be wasting time changing switching from keyboard to mouse? It can also do pattern matching, indent code, display line numbers or go to a specific line. Most of the time, the features are available, you just need to find them in the documentation. If an IDE had all the features Vim has on a graphical user interface, it would become unusable and it would be considered as bloated. Vim only weights around 6M.
If you are comfortable with command line, you can also apply commands on your code and perform operations like sorting a part of the file or filter lines. Your imagination is the only limit.
Vim is installed on most Unix and Linux systems by default and a Windows version is also available. In fact, you might have it installed and not know about it. If you have a shell access on a server, the server probably has it installed and it allows you to edit a file as if you were at home in your favorite environment. It can save files using an end of line characters and in any file encoding.
It’s a very mature editor and also one of the oldest one available. Millions of programmers use it. Actually, it’s probably the Open Source community’s favorite editor. Vim (or VI for short) is probably the most frequent answer you will get when asking F/OSS programmers which editor they are using. I have been using it for nearly two years. When you are used to it, it’s as easy and natural as breathing.