Thursday December 22, 2011

Repeat Text Actions Like Vim In Any Cocoa Text Field

As Brett Terpstra channels unreal levels of productivity and Mac-hack goodness, he discovered a built in way to repeat text commands n times just like vim.

Besides the power of modal editing, one of the reasons I like vim is the ability to repeat text manipulation commands an arbirary number of times. Want to delete the next three lines of text? Type 3dd in normal mode. Want to move up 10 lines? Type 10k. And you can get more complicated from there.

Apparently, Cocoa has this kind of power built in, you just have to tweak a setting to turn it on. Brett is the one man repository of tweaks to get Cocoa text fields to do all kinds of amazing things. This repeat trick bumps it all to a whole new level. Check out his other tips for Cocoa editing fields, too.