Bram Moolenaar, creator of the Vim text editing environment has a great article on how to think about editing text files quickly - especially in his editor.
I guess after years of editing the code to a text editor, Bram has had many hours of time to think about the aesthetic value of what he was doing .
I once read an interview with Bill Joy where he was talking about his creation of the vi editor. He said that it was really necessary because, at Berkeley, he was on a very slow connection and the rather heavy emacs load / execute time was just a killer.
So yesterday while I was sitting in ballroom 19AB and each additional laptop brought the available bandwidth from a garden hose to a swizzle-stick, I was able to understand the wisdom.
34G 3w 5cw ESC ^ 5j DD :wq!
When you work in the UNIX / CLI-environment a simple fact of your work environment is that you simply must have a high-powered text editor to edit configuration files, write code, or write email in a non-GUI mail tool. You have your choice of consumer-targeted editors (pico), but the two that battle for the power user demographic are vi and emacs.
I’m conversant in both and have even written an encomium to the power of emacs on this very site. But I should like to dwell on an interesting aspect of the vi/emacs approaches to doing things.
I had occasion to reflect on vi/emacs as writing tools when I was giving my exceedingly patient girlfriend a bit of a demo of how to use vi ( being knee-deep in drupal, it is something she’s considering needing to know more about ).
I’ve been away a while because I’ve been working very hard on migrating my legacy application. After hours and hours of punching a way in Vim, Perl, M4(!), and making screencasts the last thing I wanted to do was come home and type some more.
The interesting thing is that some of the work that I have done is able to be discussed in a public forum, so I’ll actually be able to show not just tell.
In all this typing of late, I’ve been using the vim editor for many, many hours. Given that the MacBook Pro seems to be the de rigeur tool for the modern hacker, has anyone come up with a solution on how to avoid this problem:
Vim is a great editor. I like to use it when I’m in the shell and don’t have access to Textmate or don’t want to wait for Textmate to load up.
Mapping something in insert mode, to save typing inoremap <C-E> \={E} This creates an entry in insert mode such that Control-E types the LaTeX code for an majuscule E with macron.
Consult Yegappan’s guide to map
Don’t use Escape On keyboards in the US, Control-[ is equivalent to ESCAPE, and thus can get you out of insert mode into normal mode in a slightly more reasonable setup than reaching for escape.
I have been wanting to get the Vim Editor working as a tool for blogging. I’d discussed this a time or two with my friend Daniel Miessler, and he brought up a critical thing that was missing for him in migrating away from Textmate: the ability to do an “I’m feeling lucky” hotlink onto a word as one is composing.
I had to admit, this was a pretty compelling feature provided by Textmate’s “Hyperlink Helper” bundle. Its lack definitely hindered my drive to blog in vim.
To that end, I have created my first Vim plugin and port this sexy capability to Vim.
As I mentioned elsewhere, my friend Daniel Miessler said that he would be ready to give up Textmate for Vim but were it for the level of blogging support. I have, hopefully, made it easier to do so. In fact, I’m writing this blog post and using my fork of Vimblog to manage it.
Here’s how this post was made:
:Blog np created a new post Moved down to the Categs line and then: :Blog cl /Techno to match the right line. Hit enter. Vimblog just copied the category name to the yank clipboard for me and then… p to paste it in G to the end of the file o to start typing Typed Daniel Miessler v2b\gifl did a Google I’m feeling Lucky to his site and wrapped it in a markdown link More editing :Blog draft (because it’s still alpha-grade code) so I could check it out in Wordpress Took a screen-shot of vim to put in the post :Blog um ~/Desk/vimb Vimblog pasted the url link to the image that makes this work: Published this post with :Blog publish
Introduction The Vim editor has a built-in function for preserving your editor state – which files you had open, which tabs they were in, etc. – called “Sessions.” In my experience, few Vim users, even experienced / advanced users, take advantage of this feature and that is a shame. Sessions allow you to get you back into the working context of a given problem immediately . If you’ve avoided a needed reboot for software update or wished you could save the context of your editing as related to a specific problem, you should take the time to learn a little bit about sessions.
Introduction It’s not often that many of my favorite tools intersect in an exciting way such that I find myself being saved tons of time, but it happened today and I thought I would share a powerful editing technique. The tools used were vim and ack. The payoff was to make 250 changes across dozens of files with three simple command-line operations.
The Setup I’m a real fan of the EmberJS JavaScript MVC framework.
Today the Ember team announced the 1.0-pre release of this product and I was anxious to implement it with my work codebase.
After slotting the new version, on initial boot up of my app in Chrome reported 245 errors.
I recently needed to rebuild vim from source.
Mostly people download the latest using Homebrew, but sometimes you might
need to build it from source.
It’s simple enough. Clone the git
repo.
We then create a file that we’ll pass to the shell. It’s basically a convenient
way to execute a really long command. Here’s my file. I called it myconfig.sh
Recently at work we decided to run a linter to check our spelling. This
produced a lot of output from years of, uhm, typos. The errors found (and
exceptions that needed to go into our custom dictionary!) were saved in a JSON
file. I was looking for a way to use this JSON file to help vim help me work
through this backlog efficiently. Vim proved up to the challenge when I
configured the following values correctly.
:makeprg
:make
- The quickfix window
:errorformat
I’ll give a strategy for using these in the extended post.