---
title: Convert Ruby 1.8 to 1.9 Hash Syntax
teaser: 'Using Vim or your shell, convert old-school hashes into new-school hashes.

  '
tags: web,ruby,vim
author: Dan Croak
published_on: 2012-02-11
---

In Vim, for an entire file:

```vim
:%s/:\([^ ]*\)\(\s*\)=>/\1:/g
```

In the shell, for an entire project:

```shell
perl -pi -e 's/(?<![:]):([\w\d_]+)(\s*)=>/\1:/g' **/*.rb
```

Now, instead of those old-school hashes like this:

```ruby
get "/", :agent => MOBILE_BROWSERS do
```

You'll have new-school hashes like this:

```ruby
get "/", agent: MOBILE_BROWSERS do
```
