Monday, April 13, 2009

Yank S-Exp

If you're hacking a Lisp dialect in Vim, you can do type ya( to yank the current s-exp into the default buffer.

7 comments:

graywh said...

You mean register. And a( is just another text-object. Every Vim user should know them all.

The help also says it can select [count] blocks, from [count] [( to the matching ) making it easy to grab the current and surrounding s-exprs.

Travis Whitton said...

Please excuse the semantic shortcomings... (grabs morning coffee), and yes, it is just a text object (which I posted about in 2007).

Leslie P. Polzer said...

Why not just use y% on one of the parens?

graywh said...

Leslie, using y% requires your cursor to be on one of the parens. Using text-objects doesn't have that same restriction.

Leslie P. Polzer said...

Thanks, that's a great hint for me (80% of my writing consists of sexps).

Christopher Suter said...

I believe that the a( cmd takes a count so if your cursor is inside a multiply-nested expression you can use 2a(, 3a( and so on to refer to outside s-exprs

James said...

Ok this hint is really useful! Going to use it when I start coding Clojure :) Thanks for this.