Fork me on GitHub

Today I learned: Vim

Ruby text objects Fri, 18 Jul 2014

Yesterday I discovered a text object within Vim that I’d not realised existed, which served as a perfect tip post up onto this blog (and to try and get back to doing it more regularly!).

Any seasoned Ruby + Vim user has probably got Drew Neil’s textobj-rubyblock plugin installed, which adds the text objects ar and ir to select around and inside a ruby block.

However, what I didn’t know about was the text object im, which is provided by vim-ruby (which comes with Vim by default), to select the contents within the current Ruby method, and its sibling am, to select around the method. Hat tip to @tomstuart for that one:

Drew Neil (@nelstrom)) then followed up explaining that it was recently added to vim-ruby:

If you’re running a recent version of Vim you should have this functionality, but if you’re not, you can always install the latest version of vim-ruby as a plugin through Vundle / Pathogen. The best solution though if possible is to simply upgrade your Vim.

Whilst reading to produce this blog post I also discovered the objects iM and aM, which select in and around the current Ruby class, too. All of these are going to be really useful in my day to day development.

Recording Macros for Super Efficiency Thu, 01 May 2014

Better Pasting from the Clipboard Tue, 18 Mar 2014

vim-dispatch: I should have used this years ago Thu, 13 Mar 2014

Repeating last command-line with `@:` Wed, 29 Jan 2014

Automatic Comment Prefixing Revisited Mon, 30 Dec 2013

Swapping Pathogen for Vundle Sat, 28 Dec 2013

Jumping to last cursor position Fri, 27 Dec 2013

The CamelCase Motion Plugin Fri, 20 Dec 2013

In Place code execution with Pipe2Eval Tue, 27 Aug 2013

Clearing the Search Highlight Thu, 22 Aug 2013

Awesome JS Auto Completion Wed, 21 Aug 2013

Swapping background quickly Wed, 31 Jul 2013

Live in-place Ruby execution Mon, 24 Jun 2013

Searching again with // Thu, 20 Jun 2013

Ways to quit Wed, 05 Jun 2013

Vim's `lcd` command Tue, 04 Jun 2013

vim-ruby Thu, 30 May 2013

Automatic Comment Prefixing Wed, 29 May 2013

Sorting a selection Fri, 24 May 2013

Stop Vim being slow when using rbenv Mon, 20 May 2013

Making `j` and `k` work on visual lines Thu, 16 May 2013

Aliasing g Thu, 02 May 2013

Deleting Lines that don't Match a Pattern Wed, 01 May 2013

Vim Scratch Plugin Tue, 30 Apr 2013

Binding Caps-lock to Control and Escape Mon, 29 Apr 2013

Extending Visual Selections with 'o' Fri, 26 Apr 2013

Vim Startify Thu, 25 Apr 2013

Easier Reindenting Wed, 24 Apr 2013

The Command Window Wed, 24 Apr 2013

Subscribe: RSS Feed.

TIL: Vim is another side project by Jack Franklin.

I'm by no means a Vim expert, but wanted to share the things I learn in Vim as I attempt to get better and more efficient using it. I figured documenting it somewhere where others can see and contribute was a good way to do it.