bling on software development

when pragmatism meets minimalism

Asynchronous Eval in Emacs With Stylus and Skewer

You haven’t experienced Emacs if you haven’t experienced the power of C-x C-e. This is the magical keybinding which evalulates the current line. Another useful companion is C-M-x, which evaluates the current function.

Lisp dialects naturally work with these patterns seamlessly, and once I figured out the possibilities of this I got addicted and wanted it available in all of my languages. It’s like having a debugger available all the time. But unlike debuggers where you inspect and change variables at run time, and then need to translate your changes back to code, in Lisp you just edit the code directly and eval (and repeat until you like the result).

Emacs as My <Leader>: Vim Survival Guide

Two months ago I blogged about switching from Vim to Emacs. Today, Emacs is my main editor. I’ll try to keep this post short and to the point, because there is a lot to cover! But by the end of this post you’ll have to answer to the question whether you should give Emacs a try.

What is a text editor?

If we’re just talking about using Emacs as a text editor, then there is no comparison; Vim beats it, period. But is our job description a text editor? No. We are system administrators, software developers, web designers, etc. A text editor is a tool that we use to do our job (or hobby). And any tool should be replaced when a better option is available.

One simple example is grep. As a developer, you can immediately gain a productivity boost by replacing it with ack or ag. Do they search faster than grep? No. But since they’re so good at ignoring things (like your .git directory) that for practical purposes they end up saving you a lot of time.

As a text editor, I think Emacs is quite terrible. Its key bindings are notoriously bad to the point that something called Emacs pinky exists. If you’re an Emacs user not interested in Vim bindings you should seriously consider taking a look at god-mode or control-mode. But where Emacs really excels is all of the things outside of text editing.

Emacs is a great operating system, if only it had a good text editor.

Well, the nice thing about an operating system is that you can write a text editor for it; that text editor is called evil-mode.

Now, as a text editor, Vim is still better than evil-mode for obvious reasons, so if you’re just swapping it out you’re at a net loss of productivity in terms of text editing. However, what you gain from all of the other things that Emacs can do far outweighs the missing features.

Emacs as My <Leader>: Evil-mode

Hey guys, I just wanted to post a quick demo video on evil-mode.

The video is targetted at intermediate/advanced Vim users, so if you’re just starting out you might miss some things. But…hopefully it’ll be an enjoyable watch regardless!

Let me know what you guys think of it!

Vim in Emacs Bootstrap

Did I wake up on the wrong side of the bed?

My New Year’s resolution for 2013 was to learn Vim. I was so new to Vim that I did not even know how to join lines properly. However, I was diligent, patient, and stubborn enough to stick at it. It didn’t take long for me to fall in love. I even ended up writing a plugin for Vim that got so popular that I was writing VimL as a second job.

Sounds like I’m pretty happy with Vim (and I am), so why am I trying Emacs?

Curiosity is a major reason. But more I think the philosophy of Emacs fits my personality better. The Vim community is very much divided into two camps: the text editor people, and the people who try to turn Vim into an IDE. I am in the latter. My vim distribution has over 90 plugins. While I haven’t yet run into Vim’s limitations of trying to use it this way, I can already see the walls coming up…

But here’s the thing, I’m addicted to modal editing, not Vim.

Modularizing VimScript

The prerequisites

First off, there are two very good resources that are required reading in addition to what’s provided in the official documentation. Steve Losh’s Learn Vim the Hard Way is an excellent book and I highly recommend it. The IBM Series by Dr. Damian Conway is another great resource. Without these I would not have been able to do what I have achieved, so thanks to them!

Where I started

When I first wrote vim-bufferline and vim-airline I was very much a newbie Vim scripter and I tried to follow as many existing patterns as possible. It was evident that the community at large had a very “C-like” mentality, in that most things were done with functions declared in the global scope (I don’t know if this still holds true for modern C development, but as an expression I think people will get what I’m saying). Many of the older scripts (pre GitHub) tended to be large, single file plugins which lived under the plugin folder. For example, EasyGrep is a 3000+ line plugin that helps you search and replace in Vim.