After almost a whole month of using MacVim, I think I can safely say I’m a convert. Whenever I felt I was getting really good with it, I’d switch over to SublimeText and realize I was still much better at moving text around and editing whole blocks of code inside of a GUI editor.

Today after editing some code, I flipped over to SublimeText to realize I wasn’t working any faster, and in fact missed some of the quick delete commands like dt" or D I was so used to with Vim.

It actually took a bit longer than I thought it would take. Luckily anything you want to do you can find fairly quickly with Google and StackOverflow. Many times I thought, “It sure would be nice if I could do x with a vi command” and sure enough I’d type into Google “vi how to x” and there would be quite a few results explaining how to do it.

The other nice thing that happened is when I do work on config files on my servers I am now EXTREMELY good at it. Before this month I’d “sudo vi” an important config file and at some point “:q!” because I’d hit the wrong key. Now it feels so comfortable I think it’s made me a better admin.

One thing happened I wasn’t expecting on my road to Vim: I am not actually using Vim. Instead I’m using something called Vico which has many vi key-bindings but an entirely new codebase.

Vico

You can also import tmBundles and tmThemes if there’s something from Textmate you want:

bundles

MacVim always felt like a half-step toward OS X (requiring the Janus distribution and a fork with a file browser to fill in the holes) where Vico is solidly an OS X app. For example, searching with ack brings up a nice window reminiscent of Textmate:

searching

But the most important thing is that it supports so much existing vi key-bindings that it doesn’t take long to go from (Mac)Vim to Vico. The only thing holding me back was the price: $39.99, but as the trial version was expiring I realized I wanted to use Vico past the trial date so I just bought it.

(Thanks to kob for pointing Vico out to me when I first started this project.)


I did this today. I thought I’d write it up so I can remember for next time.

I’m working on another project using Django and have liked using the ORM more than any other of the big Python ORMs out there. On MLKSHK we use the beloved FlyingCow, one that we (Ivan) wrote, but when working for clients I like to use as much existing, tested code out there as possible.

First, create a new directory in the root of your project. Throw two files in there: __init__.py and models.py.

Next, create a settings.py file in your project, fill in the necessary stuff for your database and for INSTALLED_APPS include the name of the directory you made. In this case I made a directory/module called “orm”.

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': '',
        'USER': '',
        'PASSWORD': '',
        'HOST': '',
        'PORT': '',
    }
}

INSTALLED_APPS = (
    'orm',
)

Now create your models in models.py. Note the Meta class.

from django.db import models

class Doink(models.Model):
    name = models.CharField(max_length=25, blank=True)
    created_at = models.DateTimeField(auto_now_add=True, null=True)
    class Meta:
        db_table = u'doink'
        app_label= u'orm'

The first attribute:

db_table
is self-explanatory, but
app_label
is there to help Django know this is part of the orm package. Normally it would infer this from the module it lived in inside of Django but since we’re not in Django it breaks without it.

Last thing you need to do is set the DJANGO_SETTINGS_MODULE environment variable:

export DJANGO_SETTINGS_MODULE=settings

You can now run

django-admin.py syncdb  --pythonpath=.
and your models will be created.

In your code, use your models like normal:

from orm.models import Doink
Doink.objects.all()

Doink will now work like any other Django model.


After a couple days of using MacVim and not exactly liking NERDTree, I installed this fork that provides a very nice Mac-like file browser.

MacVim Alloy Branch

I also found out about an OS X application called Vico that attempts to merge the goodness of vim with the look and feel of a typical Cocoa application. It looks very nice, but also $40 so I am going to wait until I’m good with vim before giving the 15-day trial a spin.

Overall I’d say I’m back up to normal productivity, and it feels like every hour I spend with it I discover a new way to to do something.


Some friends were talking about National Novel Writing Month and since I don’t have an idea for a novel but felt like trying to accomplish something in November, I decided to switch my text editor to vim. Specifically MacVim which I think is an important distinction I’ll explain below.

Now, I learned vi back in college in 199ksjdfl and I use it regularly on servers because pico without an actual GUI to click on locations is cumbersome and most of what I need to do when editing server files is delete whole lines or replace a value or add a new line.

Since I already had a basic grasp of vi and people seemed to think they were more productive with vim, I figured it might be time to see if it would work for me.

Starting out I think I had three concerns:

  • I use file tabs and the file browser in my current editor Textmate a lot. So much that I didn’t think switching to vim would be able to address that given what I knew about vim.
  • I love my current theme Vibrant Ink, which I wasn’t ready to part with.
  • It’s confusing. And not in a way that I thought’t I’d never get it, but more in that I didn’t want to give up a week of learning to become only a bit more productive. I’m in the middle of a big project for a client and I didn’t want to be billing them for my slowness.

So last week I did some poking around and it turns out there’s something called ‘vimtutor’ already installed on OS X. I started it up and discovered I knew a lot more than I realized. If you’re on a Mac and have about a half hour you should try vimtutor right now. If you know a bit about vim already it will be a breeze. When I finished I knew I could keep going with learning vim so I did some more reading.

The next two things to really convince me I could do it was:

  1. Finding out there was a Macintosh specific version of vim called MacVim that is a self-contained, windowed Cocoa application. This is good because there are some key-bindings in place that you are probably used to that don’t exist in standard vim. Hitting ⌘s in MacVim will actually save your file. You can use your mouse to select text and holding shift + moving your cursor around will select text.
  2. Installing a vim distribution called Janus that installs a whole mess of plugins and tools that make transitioning to vim much easier. There’s a file browser (like in Textmate) and it even comes standard with the Vibrant Ink theme (type :color vibrantink) or set it up in your new .vimrclocal file by adding “color vibrantink” without the quotes. There are a lot of themes.

After this, I read these blog posts:

And then I wrote this blog post you’re reading now in my shiny new compiled version of MacVim.