Thursday, November 8, 2012

Vim Motions

One of the more frequent admonishments delivered on #vim to the whining novice or the curious journeyman is to master the many motions within the editor. Previously, a bewildering list of punctuation and jumbled letters was unceremoniously dumped on the complainant with the misguided expectation that they'd then take themselves off and get right to the task of memorising the eighty odd glyphs. We mistook their silence for compliance but I rather suspect it was more bewilderment or repulsion or sheer paralysis. In an attempt to friendly that mess up, I have started an infographic series intended to cover the twelve major categories, probably spread over six separate infographics.

The Vim Motions Infographic Series (in 9 parts):

1. Line & Buffer
2. Column
3. Word
4. Find
5. Search
6. Large Objects
7. Marks, Matches & Folds
8. Text Objects (not motions, but mesh nicely at this point)
9. Creating your own Text Objects

I plan to have a different expression on the chibi's face in each of the pages. I'll move the crying one from the Large Object page (as shown below) to page 1 and then progressively improve her mood through the remaining pages: something like -- crying, disappointment, resignation, hope, amazement, happiness, confidence, smugness and something devilish. As an update on that, I have inked five of the chibis now. I look forward to having them all up in their own infographics.

I decided to have the background colour change to suit the mood of the chibi, starting from black in image number one to represent depression and despair. I will roughly follow the same colour spread I used on the How Do I Feel graphic.

I have no experience in putting together a multi-page piece like this. Feedback certainly welcome. I was vaguely thinking of having it a bit like a magazine or comic book spread, but I don't know how to do that or whether it's the right or even a good approach.

Green indicates cursor origin before issuing the motion.
Red indicates cursor destination at the end of the motion.
Orange shows the area covered by the motion. This would be the same area highlighted in Vim if a visual operator was used with these motions.

1. Line & Buffer Motions

2. Column Motions

6. Large Object Motions

The Many Faces of % in Vim

Pity the poor Vimmer for he has so many a face to put to percent:

Help Topic Description
N% go to {count} percentage in the file
% match corresponding [({})] (enhanced with matchit.vim plugin)
g% enhanced match with matchit.vim plugin — cycle backwards through matches
:% as a range, equal to :1,$ (whole file)
:_% used as an argument to an :ex command as the name of the current file
"% as a register, the name of the current file
expr-% in VimL as modulo operator
expand(), printf() and bufname() in VimL use % in printf-like format specifiers
'grepformat', 'errorformat', 'shellredir', 'printheader' and 'statusline' various options use % as a printf-like format specifier
Regular Expression Atoms:
Match locations:
\%# cursor position
\%' position of a mark
\%l specific line
\%c specific column
\%v specific virtual column
\%( non-backref capturing group
\%[ sequence of optionally matched atoms
Numeric character specifier in matches:
\%d decimal
\%o octal
\%x hex (2 digits)
\%u hex (4 digits)
\%U hex (8 digits)
Absolute file or string boundaries:
\%^ start of file (or start of string)
\%$ end of file (or end of string)
\%V match inside visual area

Thursday, November 1, 2012


A true and accurate hysteri of the Rise Of The House Buffalo.

This chronicle begins on the 3rd day of the 7th month in the time of Our Vim where people lived a modal life of happiness and abided the :ex commands with pious fervour and so were blessed with edits most excellent and help abundant. It was a time of peace, prosperity and personal productivity.

Then one fateful day a churlish stranger peddled into town, seated upon a contraption most vile and contemptuous. Perched high atop its mechanical crown he screeched down upon the startled fray: “Tarry not betwixt thy :buffers and switch thee not so slowly as with a :buffer number or partial match thereof! Hark the word of reason and join your wizened brethren in celebration of the wheel! Cycling is thy salvation!” So bold was the orator and so balanced he atop his levered contrivance that several among the crowd, wide eyed and jowls agape, moved toward the wretched apparatus with minds numbed and coveting limbs trembling outstretched in wanton avarice.

Lost were these souls on the dull carousel of endlessly needing to :bnext to their buffers; pitiful prisoners of self-constrained linear, cyclic thinking. Trapped they were in the dungeons of their own device, tormented by the clink of their own chains, damned to traverse the wheel of life for eternity, forever spun without liberation.

Forever, that is, until the mavericks started flying.

Unconvinced by the rhetoric of the Church of the Wheel, various voracious vimmers revolted against the Cyclic Dogma and instead embraced a more direct buffer navigation strategy they dubbed flying. This upstart movement quickly gathered an ardent band of kindred spirits who championed the righteousness of flying over cycling.

Regretfully, the zealous were much harder to shake free from their demonic wheel worship. Skirmishes frequently lead to larger battles, some of which erupted into full blown flame wars involving some very hurtful name calling. Slowly waged this war of ideologies, its opponents forever locked in a struggle for vimmer mindshare.

That all changed when Brother Raimondi rode into town astride a bullock of majestic poise and serious presence. The unassuming fellow dismounted without word, turned to the gathered townsfolk and, lifting his feathered cap in measured civility, said, “I bring you The Buffalo.”

No ordinary ox was this tireless beast! Fast, it was! And nigh on omniscient — inferring your very intention from the merest mumble of your desires. So stunning was the stuff of this beefy buffer bouncer that even acolytes of the Church of the Wheel were leaving the order and forsaking their old cycling ways as sin against good sense and refined taste.

For many millions of clock cycles did the mighty buffalo reign over the land of Vim with an ever brisk gait and unerring (ok, only slightly erring) eye toward buffer discretion. Though happy were the citizens with their bovine bureaucrats, they shared a secret longing for simpler governance, clearer models, a more transparent core. Their collective desires created an exaltation of excellence within the very genes of the tenacious bison herd.

Indeed, the metamorphosis was nothing short of a total paradigm shift. Thus dawned the era of the formidable SkyBison — a wondrous hoofed though winged beast, swooping down from aloft in clean and graceful yet swift and precise arcs of buffer selection. May the SkyBison reign righteously and with longevity.

The buffalo is dead; long live the buffalo! All hail the SkyBison!

And if you’re still cycling when you should be flying… may SkyBison gorge on your artless cud.

Note This is a work of fiction only. Any semblance to peoples either living, dead or pretending to be so is purely coincidental and should not be taken as pertaining to them in any way whatsoever. Unless you feel flattered by the events described herein, in which it’s totally about you. Don’t mention it. You’re welcome. You’re worth it.