Sweeten Your Vim with Cream

It’s an eternal debate amongst Penguinistas: Emacs or Vim? Unfortunately, for most” normal” (i.e., non-geek) folks, this debate will never occur, since they will find Emacs or Vim way too complicated, strange, and, well… different. You’ve heard what these new users say when they meet Emacs or Vim:” Why doesn’t anything appear when I type? What’s up with these weird key combinations? I have to do what to save? Modes? What are modes? I hate this! Why can’t I just type and save like normal?!”

This is really too bad, since Vim has a tremendous amount of power, stability, and extensibility to offer users (Emacs… ahhh, not so much). But if users are scared or confused by the interface, they’ll never get to enjoy the good stuff that Vim has to offer. There has to be some way to ease users into Vim, some way to leverage the power of Vim while accommodating, or even overcoming, the steep learning curve. Fortunately, there is a solution: Cream.

In order to use Cream, you have to have Vim installed. In fact, the program called” Cream” is really a series of scripts that extend Vim, adding and changing key commands, providing new tools and features, and simplifying the way the program works overall.

It’s an added bonus that, because Cream is just Vim underneath, power users comfortable with Vim can still take advantage of their muscle memory and years of learning. And perhaps the nicest extra of all is that Cream is open source, free, and runs on Linux and Windows.

I’ll Take Some Cream, Please

Installing Cream couldn’t be easier. Users on Ubuntu and other Debian- derived distros can simply run sudo apt-get install cream, and a few moments later the program will be on their systems.

SUSE and other RPM- based distros can use YaST, YUM, or whatever system package manager the distro comes with to install Cream, as it is provided by virtually all major distros. If your distro doesn’t provide what you need, or if you’re running Windows, head over to the main Cream website where you can download a binary or source code.

Now that Cream is installed, start it up. If you’ve ever used Vim with a GUI before (most likely GTK+), you’ll notice that Cream looks on the surface just like Vim. However, once you start poking around the menus, or begin typing, you’ll immediately see that Cream has been carefully designed to make Vim more user-friendly and more like the text editors most people are used to.

Most obviously, the idea of modes is gone. If you’re used to pressing i or a to edit and Esc to enter commands, this may seem crazy… but then, Cream wasn’t created for you.

What else is different? Quite a bit, actually.

Common keyboard shortcuts. Cut is Ctrl-X, Copy is Ctrl-C, and Paste is Ctrl-V, just like almost every other editor out there. And that’s the point. Same thing for Ctrl-Z (Undo), Ctrl-Y (Redo), Ctrl-S (Save), and Ctrl-N (New).

Not everything is exactly the same as common text editors, however. Ctrl-F brings up a nice little Find window, but you use Ctrl-H for Replace, not Ctrl-R. Take a stroll through Cream’s menus, and you’ll find that you already know most of the key commands, since they come from the common user interface found in thousands of programs. As you can see in Figure 1, Vim with Cream sports a couple of new menus.

“Vim with Cream”

Format menu. A new menu- Format- contains within it a wealth of easy-to-use text-changing goodies. Want to quickly change the case of highlighted text to all-caps, lowercase, or headline? No problem. Need to delete any empty line in a file? How about toggle between wrapping and no wrapping? Got a hankering to convert tabs to spaces? It’s all there, easily accessible under Format.

Settings menu. Another new menu- Settings- also provides easy access to useful features. Within the Settings menu, users can toggle line numbers, word wrap, revealing invisibles, auto-indent, syntax highlighting, and much more. In addition, a sub-menu labeled Preferences makes it very easy to set the default font, enable a tabbed interface, allow middle-clicking to paste copied text, and, in a nod to Vim users who want to try out Cream while keeping their well-earned Vim knowledge in play, Expert Mode. Enable Expert Mode, and you suddenly have access to modes again, so you can run your favorite scripts and take advantage of all the commands you know and love.

Tools. Cream isn’t just about rearranging Vim to make it easier for novices to use; it’s also about adding new extensions that take the program in some surprising new directions as well. Most of these extensions can be found in the Tools menu.

Some items under tools are actually present in Vim, but made more visible in Cream, like spell check, macro recording and playback, folding, text completion, and diff. The last sub-menu under Tools, however, is Add-ons, and it is there that the more adventurous users should definitely venture.

Really, it has to be said: Add-ons contains some pretty cool tools. You can invert lines or strings. sort text and then uniq it (in other words, use the uniq command to sift out similar lines), or” encrypt” text using various methods, including h4xOr and Rot13. This may be acceptable for casual” encryption” – like hiding the Christmas gift list from the kids- but it’s not going to wash in any circumstance that requires real encryption.

A timestamp is available, and so is the ability to convert your text from ASCII to Hex, or vice-versa, or even to HTML (although the HTML it produces is nothing to write home about). You’ll discover many more. One quick way to get a good overview of the items in the Add-ons menu is to try the Add-ons Explore wizard.

The Add-Ons Explore Wizard

To get to this feature, go to Tools-> Add-ons Explore(Map/Unmap). You’ll see a dialog similar to Figure 2. Here you can get a description of the various add-ons, and even map the shortcut used to access the add-ons.

That’s just the beginning of Cream, and even those who are well-experienced with Vim may find something useful in the program. Install it, play with it, and maybe you’ll find out that it’s useful not just for text editor newbies, but for old hands as well.