subscribe via RSS

  • OpenFest 2012: Taking Over the World with Vim [talks, vim]

    This year, I did a talk at OpenFest about Vim. I tried to make a few interesting points about Vim and why it’s awesome. In the end, it turned out to have too much talk and not enough mind-blowing plugin demos, which I should probably work on for next time.

    For now, I’d like to quickly go over the three main points that I hope people took away from the talk. The slides are uploaded to speakerdeck, though they’re almost certainly useless without the demos and my explanations (not to mention they’re in Bulgarian).

    [...]
  • Manipulating Coffeescript With Vim, Part 2: Wrapping and Unwrapping [coffeescript, vim]

    In coffeescript, particularly when you’re dealing with nodejs, code is often wrapped with lots and lots of callbacks. Since the indentation of the wrapping function calls varies, it’s not very easy to move them around, delete them, or add new ones, because you need to adjust the indentation of the blocks of code they contain.

    In my previous post, I defined two mappings to operate on blocks of code. In this one, I’ll define two that deal with the wrapping callbacks.

    [...]
  • Manipulating Coffeescript With Vim, Part 1: Text Objects [coffeescript, vim]

    I recently started to write a lot of coffeescript at work, so I bumped into an issue that I’ve been avoiding for some time: manipulating indent-based languages. Theoretically, it should be easier (no “ends” or closing braces, right?), but I have a lot of tools to move code around, wrap it in blocks, or view it nicely, that just don’t work with semantic indentation. So, I had to experiment to come up with some vimscript to make it more comfortable. It’s all a work in progress, but it’s been rather useful for me so far.

    Originally, I intended to write a single post, but I started off rather verbosely, so I decided to make it a series instead and explain the code in more detail along the way. To begin with, I’ll describe the process of writing two simple text objects that might be useful in day-to-day coffeescript development.

    If you’re unfamiliar with text objects in Vim, you could get a good explanation from the help files with :help text-objects. Another nice introduction is Chapter 15 from “Learn Vimscript the Hard Way” by Steve Losh. It’s rather short, so I recommend you skip through it in any case.

    [...]
  • Customizing the NERDTree's Filesystem Menu [vim]

    For quite a while, the NERDTree has had some simple scripting capabilities. At some point, I decided to use these to override the basic filesystem menu it provides to something a bit weirder. My problem with the default menu was its lack of vim keybindings. Being in command mode is usually not an issue, since it’s fairly rare, but I got really used to moving and renaming files through the tree, so it was time to improve the experience a bit.

    [...]
  • Generating a Preview of a Coffeescript File in Vim [coffeescript, vim]

    I started writing a bit of coffeescript recently. One of its benefits is that the javascript it generates is fairly readable, which really helps in the learning process. To make it easier to see it, I whipped up some vimscript to open up a split window with the generated javascript and update it every time the file is saved. In this short post, I’ll just show the code and explain a bit about how it works.

    [...]
  • First Steps With Arduino [arduino]

    I finally bought an Arduino to play around with. Considering I’m studying robotics, it’s a good first step. If the word doesn’t ring a bell, an “Arduino” is a simple programmable chip. You can write code (a “sketch”) in a subset of C++ and then upload it to the board. You can wire all kinds of sensors and motors to the Arduino and build some pretty cool stuff (a sliding door, a portal turret plush toy).

    Naturally, starting something new, I ran into a few bumps. While there’s a ton of information on the Arduino forums, and even in the Arch Linux wiki, it was still a bit of an adventure to get the ball rolling on my machine.

    In this post, I’ll describe the solutions to a few of my issues. I’ll also explain how the compile and upload process works, at least to the extent of my understanding, and how to get started with building through the command-line. So, if you’re not interested in my headaches, feel free to jump down to “Step 1: Preprocessing”.

    [...]
  • Driving Vim With Ruby and Cucumber [ruby, vim]

    One of the more exotic features of Vim is its remote control functionality. Basically, if you invoke Vim with --servername SOME_NAME, you’ll be able to send commands to it with another Vim instance. Using this, I’ve recently attempted to fix a common annoyance with vimscript – its limited testability. By spawning a remote instance and controlling it through ruby code, we can use cucumber to perform simple integration testing for Vim plugins.

    This is not something I’d do for all code I write, but in some cases, it could be a life-saver. My splitjoin plugin is one example of a project that I wish I had a good test suite on, considering the amount of regressions I’ve had when modifying functionality. In this blog post, I’ll describe some ruby code to drive a Vim instance remotely and a few sample cucumber steps you could write to make use of it.

    [...]
  • Vim and Ctags: Finding Tag Definitions [vim]

    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 :tag command, 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.

    [...]
  • Making Vim Pretty With Custom Colors [vim]

    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.

    [...]
  • My Daily Sites [projects]

    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.

    [...]