subscribe via RSS
A while back, I posted an article on setting up Vim with ctags. In this post, I’ll go through the code of a small vim plugin I’ve recently published, tagfinder.vim, which is a generalization of the last example from that article. Basically, it lets you define custom commands to look for tags by their name, filtering them by a specific type – class, method, module, and so on. This doesn’t add a whole lot of value over the built-in
:tagcommand, but I find it’s still pretty useful. The idea was originally taken from Tom Link’s tlib library.
My goal is to show an example of moving from an idea of useful functionality to working vimscript. I am cheating quite a lot, since it’s something I’ve had in my vimfiles for a while now. I’ve only isolated it into a plugin, removing the dependencies and adding hooks for custom commands. This means that I have a good idea of what I want to do, so I’ll skip lots of steps in the process of describing it. Still, I think it might be useful to see the components of a simple vim plugin and how they work together. I’ll make a summary after the post with what I consider some of the more important lessons.
Pretty much all editors have the option of changing themes and tweaking colors. Vim’s no different, but instead of menus and wizards, it’s done by using vimscript. While it could be argued that this is more difficult than in a “conventional” editor, I really don’t think that’s the case. I’ve recently been hacking on my own color scheme a bit, so I’ll take this opportunity to do a post on how to manage colors in vim and achieve some nice effects.
For a while now, I’ve been working on a little website to manage some sites I visit regularly. I call it “Daily Sites” and it’s at http://daily-sites.andrewradev.com. Since it works just fine for me and I got around to writing a small about page for it, I thought it’s finally time to show it to other people with the hope that it might be useful for them as well.
Ctags is an old tool, just like vim, and it works wonders for code navigation. Since I was recently told that TextMate doesn’t have ctags integration out of the box, I figured I’d make an article explaining it. Even if you’ve used it before, I’ll describe some of my own workflow, so you might learn something interesting anyway. I’ll start from the basic usage, and then I’ll discuss things like keeping the tags file up to date and maintaining tags for any libraries you might be using.
I’ve always thought generating select tags was a bit odd in Rails. There are various choices and it might be difficult to decide which to use in a specific situation. A popular article on the topic is this one: Select helper methods in Ruby on Rails. It’s pretty old (2007), but still relevant. I’ll go through the helpers in that post quickly:
collection_select: Mostly used for model-backed data, invoked with all the method names it needs to build up the select box.
select_tag: A lot simpler, requires the option tags as a string, which usually needs to be delegated to another helper.
select: Used with a hash of names and values or with a list of pairs. This means that you can use it for any kind of data, including one from a model, but you need to prepare it first.
What the article doesn’t cover, though, is the grouped select helpers. They’re used when you need to categorize the data with optgroup tags. There’s info on the Net here and there, but I’ll try to give a quick run-down on how and when to use them. I’ll be using the
FormBuildervariants of the helpers, but I’ll also give an example later on for non-resource forms.
Finding and replacing strings are often-used operations when editing text and vim has a full-featured regex engine to aid in that. Unfortunately, it’s one of a kind – neither POSIX- nor perl-compatible, though mostly the latter. There are various differences with perl, though, and minor oddities that can be pretty annoying until you get used to them, so I’ll try to explain a few of them here.
Note: I’ll be assuming you’ve worked with some flavor of PCRE before.
To start off, I’ll write about something I’ve actually seen interest in from people I know – my Vim configuration. I’ll try to explain my personal workflow and maybe share some useful tricks along the way. For now, I’ll limit myself to the basic stuff and exclude plugin-related wizardry, maybe I can devote another blog post to some of the plugins I can’t live without.
Hello, World 
Hi, I’m Andrew and this is my first blog post.