Friday, January 18, 2019

Fat's 2018 in Movies

Rough year. I found 135 movies (or movie-like objects, including coherent seasons of TV (Fargo, say)) on my list, but every time I have looked at that list, I have had to close it in despair. And now I'm trying again. Order is mainly chronological by when I saw it.

By far the best times I had in the movie theater were: The Rider, Stop Making Sense, and Free Solo. (Sorry to Bother You would have made this list, but I accidentally saw it in Berkeley, instead of my beloved Oakland.) Best home watches: The Florida Project, Marie Antoinette, Damsels in Distress, Hereditary, and The Endless, the latter two of which actually, literally, cost me sleep. Everything else I saw, I think, would have to be counted as a major step down from those experiences. (Creep and Murder Party definitely get recommendations, if you're into that sort of thing.)

Tier 1: 2018 Good Stuff

  • The Florida Project
  • The Rider
  • Autopsy of Jane Doe
  • Sorry to Bother You
  • Leave No Trace
  • Free Solo
  • Hereditary
  • The Endless

Tier 1a: Good Stuff I Didn't See Until 2018

  • Wild Things
  • Walker
  • Good Time
  • Cruel Intentions
  • Stop Making Sense
  • Marie Antoinette
  • Children of Men
  • The Cutting Edge
  • Damsels in Distress

Tier 2: Okay / Above-Average / Decent / Memorable Stuff I Saw (or Maybe Rewatched) in 2018

  • Okja
  • The Dressmaker
  • The One I Love
  • The Intervention
  • Phantom Thread
  • Free Fire
  • Black Panther
  • Mom and Dad
  • The Square
  • The Killing of a Sacred Deer
  • Marjorie Prime
  • Jurassic World: Fallen Kingdom
  • The Gift
  • A Cure for Wellness
  • American Made
  • Devil in the Blue Dress (good rewatch)
  • Halloween (new one)
  • Into the Forest
  • The Overnight
  • Creep
  • Murder Party
  • rewatched Boogie Nights: yeah, holds up Party
  • Piranha (whatever, I liked it)

Yes, I Saw That

  • mother!
  • 47 Meters Down
  • The Shape of Water
  • Last Jedi
  • Annihilation
  • Red Sparrow
  • Avengers
  • The Commuter
  • Nocturnal Animals
  • Ravenous
  • The Meg
  • Byzantium
  • Ant-Man & the Wasp
  • Hold the Dark
  • The Apostle
  • First Reformed
  • Unsane
  • Blockers
  • Call Me By Your Name
  • Crazy Rich Asians
  • The Ballad of Buster Scruggs
  • Only God Forgives
  • The Spy Who Dumped Me
  • Skyscraper

Worse Than That, I'm Not Even Gonna Mention

Stuff I Saw but Somehow Forgot to Put on the List

  • Days of Heaven (obviously Tier 1a)
  • The Reef (obviously Tier 2)
  • Adrift (hmm...)


Friday, January 11, 2019

PEN 15 Club: rubbing one (competitor) out

It's come to our attention that other people are writing about pens. This is, clearly, completely unacceptable.

That said, the errors and failures of others can help us understand our theoretical contradictions and then revolutionize them in practice by eliminating the contradictions. So in that spirit, let us examine The Strategist's piece on ... the 100 Best Pens. JFC. That is a LOT of pens. To have opinions about, that's a lot of pens. Therefore, let us examine two things: their theoretical underpinnings / methodological preliminaries; the pens they talk about that we have already talked about.

What matters to The Strategist.

  • Smoothness
  • Smudging
  • Bleed-through
  • Feel (they mean hand feel)
  • Looks

The first three of these make fairly little sense without considering the writing surface, of course, and their strategy for dealing with this is to wave their hands standardize what they're writing on to one single notebook (and not an inexpensive one at that). That this makes their testing a pernicious parody of what it's like to take one's pen(s) out into the world is an unintended, indeed, unacknowledged consequence of an obvious, and complete, failure of theory.

They discuss "Smudging" at a number of junctures, but never is waterproofness mentioned, an omission for which an appropriate epithet has yet to be discovered. I mean, writing a check? That's an important activity to me, yet nowhere in their 100 reviews is this prosaic activity present. And this is relevant, because if you follow the recommendations here, you're gonna need to write some serious checkage: there are at least three pens in the three-figure range here, which seems an odd juxtaposition against $13-for-50 Big Cristals. To say nothing of their catastrophic lack of notes on which pens can versus can not be spun, debate-kid-style, across one's thumb. Even to consider their rankings, founded on such an incoherent and incorrect mishmash of criterions, must be accorded no more, yet no less, than an act of charity.

Let's get down to it, boppers.

Our most compendious previous write-up included the following pens. I shall list them below, helpfully ordered from top to bottom, each pen annotated with our ranking, followed by The Strategist's placement in their list of a hundo, and finally, a brief disquisition on the relative amount of insanity displayed by the strategery reviewed.

  1. Bic Cristal
    Reviewiera Ranking: 9/10
    The Strategist Ranking: 63/100
    Insanity Ranking: These clowns. These ridiculous, perverse clowns. I'm not saying everybody has to rank "Availability, reliability, incredibly cheap price" as highly as I do; nor am I claiming everybody ought to enjoy ballpoint pennery: but to rank by my count some twenty-two ballpoints as better than this one? is an act of actual depravity. And every character of the following passage makes me angrier than the last: "The angular, hard plastic body quickly becomes uncomfortable in the hand. It’s a reliable, affordable pen for jotting down quick notes, but not something you would want to write with for an extended period of time".
  2. Pilot V5
    Reviewiera Ranking: 8.8/10
    The Strategist Ranking: 16/100
    Insanity Ranking: I'm now thinking I might have overrated this pen slightly: it's a good, even excellent, pen, but it writes a tiny bit too fast, contributing to my handwriting losing what little legibility it has to this point retained. But top-20-percent of all pens deffo sounds right. Into it.
  3. Le Pen
    Reviewiera Ranking: 8/10
    The Strategist Ranking: 18/100
    Insanity Ranking: Everybody loves these! Everybody's right.
  4. Micron ~art pen~
    Reviewiera Ranking: 7/10
    The Strategist Ranking: 34/100
    Insanity Ranking: Basic agreement here, but bonus points for the most insane thing I have read this week: "but because it’s shiny plastic I think it might make my hand sweat a little.". (Note that this is the third consecutive pen on my list that can correctly be described as "shiny plastic"; my hand sweating on my pen is ... not an issue at this time.)
  5. Pilot G2
    Reviewiera Ranking: 6/10
    The Strategist Ranking: 31/100
    Insanity Ranking: Predictably, Strategist types, like the entire rest of the world, overrate this pen enormously. Typical.
  6. Uniball Vision
    Reviewiera Ranking: 5.5/100
    The Strategist Ranking: 61/100
    Insanity Ranking: We seem to agree on this one.
  7. Paper Mate
    Reviewiera Ranking: N/R
    The Strategist Ranking: 53/100
    Insanity Ranking: I didn't rank this one for complicated reasons having to do with the only one I have on hand dating back to my father's funeral, but, honestly, middle-of-the-road/pack seems about right for this extremely reliable but hardly fancy option. Plus, I think I just like ballpoints more than the next guy, which I have learned via this exercise.

But nobody, and I mean nobody, could like ballpoints enough to justify this ... monstrosity.

(Calling ... this an acceptable writing experience, let alone calling it the dozenth-best writing experience available is legitimately revolting. Feel: 4!? LOOKS five?? This ... is madness.)

Anyway, my current load-out is just: Bic Cristal; Sharpie®|Pen.; Pentel 205 .5 MM mechanical pencil. Total cost: somewhere under twenty Reviewieran yua (often known as (American) "wing-wangs"); total effectiveness: off the charts.

Anyway, The Strategist, welcome to the PEN 15 Club.

Labels: , ,

Monday, January 07, 2019

Vim (for non-programmers) Chapter O (NOT 0), recipes which are quick and dirty, example two: Dumping Out the Recommendations from IDEOTVPod into One File

(Or, more generally: pulling specified chunks of text from one million semi-well-structured text files, a goal probably often shared by many.)

I had been asked to help a listener pull all the recommendations from my podcast, I Don't Even Own a Television, along with what episode they came from. Since I write the show notes that go on the website, I figured I might have a quicker way to do this than manually going through every post on the site to do the ol' copy-paste. Below is what I came up with. Note: I use Ubuntu at home. The described process works because my laptop is where all the files are, and because, as we'll see, all the relevant files are set up and named the same way.

  1. Navigate to the correct directory
  2. Load all specified files into Vim's argument list—this is a pretentious way of saying "open all the files in Vim at the same time":
    From the command line, run: vim ep_*
    (This works for me because I am a martinet about file naming conventions)
  3. Type :argdo :execute "normal @m"

But what does that even mean? As usual, we have to look at this from right to left (or from inside to out).

To begin with, @m is a macro. Typing @m just means "do a sequence of key-presses that has been specified and then saved to the register m". Or at least that's what typing @m means when you're in Normal mode, which is why we specify :execute ":normal" before the macro. So there's a lot going on with :execute ":normal", but most of it I don't actually understand, so let's skip it for now, because it's complicated, and go to the macro.

The macro is a recording of key-presses. This recording can be of pretty much anything. If you have a repetitive task, a macro can make it much less repetitive. If you have a repetitive task that involves a lot of tricky typing, that's an even more enticing opportunity to use a macro. (In general, macros don't seem to get a lot of use in the Skilled Vim User community, but I think they're often a good way to do a task you have to do a whole bunch of times one day, and maybe not ever again on any other day.) What we have here is:

  • @m = /\d<cr>"By<cr>/Reco<cr>V/\/ul<cr>"By
  • / = search*
  • \d = for the first digit**
  • <cr> execute the search and put the cursor at the result of the search
  • "By = append to the b register the entire line that first digit was on—the functioning of this is a little obscure to me, because it copies the entire line when I don't think it should, but it works, so whatever.
    y means "yank (Vim slang for 'copy')", " means "look for a named register", and B means "use the b register, but I'm capitalized, so append what you're yanking to the end of whatever's in this register, instead of overwriting what's in it"
  • /Reco<cr> = search for the string "Reco" without the quotes and go there
  • V = visually select the entire line
  • /ul<cr> = search for the closing tag of the unordered list that appears in the html file under the heading "Recommendations"—doing this after entering Visual mode will extend the selecting over that whole span: the prefixed \ before the /ul is needed otherwise you can't search for the /, and hitting return, as usual, fixes the selection, and sets us up for the culminating
  • "By, which is another "append this selection to the register we've been working with"

* (for whatever is typed after the slash (in normal mode, which, remember, we specified we'd be in already; otherwise one could preface this with <esc>, which I would normally do just out of muscle memory, honestly))
** \d is of course a regular expression for "digit"

NOTE: for the sake of hygiene, this should almost certainly start off with gg to go to the top of the file, as Vim can be asked to save the last location of the cursor for a given file. So let's pretend I did that.

Finally, the :argdo bit we started with just means "do the following for every argument Vim has right now". In our case, since we opened Vim with all the files we wanted, in Step Two above, this is all the files.

Basically, then, we have one trick, done twice. That trick is "make the computer do the same tedious thing over and over again". We ask the computer to do this first, in one file, as a macro: basically, this automates the process of looking at an open file, searching for and copying the episode name / number into a new place, then searching for and copying the Recommendations section underneath it. (The macro is a dense but plausible reconstruction of the searches/copying one might reasonably do here. The only weird part is dumping everything into a named register instead of an external file.) Second, we then ask the computer to run that macro once per file for a whole pile of files: that's the :argo :execute "normal @m" bit, once the files are loaded into Vim. As for loading them into Vim, that's an operating system task. The cool part is having two separate ways to repeat: the macro and the :argdo command.

Once everything was done, I just pasted the contents of the b register into a text file and emailed it off into the world. If I needed to do this again, I would probably (look up how to) redirect the text I was selecting into a log file somewhere, and skip the register step.

It's debatable whether this was actually quicker than going through a couple year's worth of files. But at least I learned some stuff, and the work I was doing in doing so was much more interesting and engaging than just manually cutting and pasting a whole bunch of stuff a whole bunch of times. Learning :argdo alone will probably make my life a lot easier in future...

Previous entries in Vim (for non-programmers):


Sunday, January 06, 2019

PEN 15 Club 2: more on the Sharpie(r)|Pen., questions posed and answered

Well, I knew this would happen. When you say something as controversial as I did yesterday—"the Sharpie®|Pen. implement is pretty okay for writing things with" was merely the felt tip of my offensive offensive—you're going to have to expect pushback. And pushback I have from Pen Internet and elsewhere received.

Occasional contributor and life partner Pierre Idiot Trudeau, perhaps predictably, mounted the fiercest assault on my position.

I'm confused as to how these Sharpie Pens are different from the Sharpie fine and Ultra Fine markers. Is there a ball or different ink release system? I know that you've used those others I've mentioned, so I'm curious as to what makes it different/more pleasing.

Later, a pervert calling him-or-herself "Unknown"* continued the savage pile-on.

*Likely fucking story, friendo.

I have a bunch of conflicting emotions about pens. My trusty Micron is great for small missives, but if I truly want to make a statement I have a Sharpie in a holster. I tried the double tip dueling fine point/regular Sharpie, but hardly used the fine point. Turns out, I only use the Sharpie for making signs or responding to analog social media. There are a number of other instruments in my pen-theon which I will leave until another entry on which to elaborate.

"Pen-theon" is pretty good, though, so kudos for that. To address these wild accusations: I did not explicitly compare the Sharpie®|Pen. to the more common Sharpie "permanent" marker, for two reasons. First, I am a MarksALot man**, and brand loyalties are important***. Second, I mostly write on paper, and people who use Sharpie markers to write on paper make me uncomfortable (nervous, irritable). I have tried this, under the occasional influence of one disreputable brute or another, from time to time, and the overwhelming experience is one of bleed-through, of paper more ruined by ink than (ad-)dressed by it. The hand feel of a Sharpie marker is also completely vile: chub-stubby and slick—no, thank you!!

**No, I'm not.
***No, they aren't.

Recently I uncovered a smallish cache of the small-tip Sharpie markers, and attempted to deploy them to label presents. Stolen from work a job ago, they had all gone dry, nestled patiently in my art silo. The metaphor is, of course, clear.

The tip question posed by Pierre Idiot Trudeau is easy enough to answer. The Sharpie®|Pen. boasts a standard protrusive cylinder felt-tip, no ball to be found, basically the same format as the Micron art pen. The Sharpie marker, of the small-tipped variety, does, I believe, incorporate a ball encased by a plastic cone (among its other failings)****, whereas the more common "fine point" marker is a thick, slab-like cone of felt.

(Note here the tip propaganda of the manufacturer, included so that we may better understand not what to think, but what we are wanted to think, by those who are not our friends.)

****I can't verify this, because I took all the ones I had and threw them in the fucking garbage, where I assume they remain, sucking shit. I took a long look at Sharpie dot com, and could not find the sort of pen I am remembering. After additional research, I have come to believe that I may have been remembering not a Sharpie, but an Expo Vis-à-Vis dry erase marker of some sort, or a Sharpie equivalent. I fail to see how this minor error in identifying the tool I was using could in any way invalidate anything I have said about the experience of using the tool. :(

(I don't even like looking at these hateful objects.)

Perhaps more important than the tip is what comes out of it. Standard Sharpie marker ink is, as I have hinted, not my favorite thing to apply to paper (except for wrapping paper, a task that comes up not very frequently, as I am an ingenerous clod), but the Sharpie®|Pen. issues forth something that, as the container indicates, "won't bleed through paper", which is cool. Using science, I have determined that the Sharpie marker and Sharpie®|Pen. do in fact have different inks: as the image below indicates, Sharpie markers can write on glass, whereas the Sharpie®|Pen. cannot, to its credit.


So. To recap, always a good thing to do with your pen:

  • Tip differences: Sharpie®|Pen., a pleasing cylinder of felt jutting from a metal tube, like a tiny Chrysler building; Sharpie marker, a galumphing, turgid pile
  • Ink differences: Sharpie®|Pen., a kind, gentle fluid optimized for gracing, indeed grazing, paper, whence good adults write; Sharpie marker, a harsh substance perfect for those who wish to "make their mark" on arbitrary surfaces (childishly)

Of course, Pierre Idiot nor his campaign were finished.

I have specific pen/marker/highlighter needs/opinions based mostly around the paper that's getting written on. I petitioned my boss - unsuccessfully - to allow us to buy the one step up paper that we used to buy because it "feels better to write on". This was met mostly with eyerolls, but a bit of sympathy from the very same people.

Indeed! Sadly under-recognized, except by the attractive geniuses who read this post, is the vast truth that: The Paper ... Makes the Pen. The barrel matters regardless of surface, but the pen's contents and tip are wildly at the mercy of whatever you're planning to rub them on! This is one reason an ultimate pen, much like an ultimate morality, can likely never be discovered. As for your boss, I recommend collective action and concerted activity. Be unwavering in your demands, unstinting in your efforts, and unquenched in your desire for total victory (read: slightly better office supplies). You might try framing it as a workplace safety issue, if you can. "Paper cuts are causing paper cuts" is a slogan I can hardly imagine meeting with anything but immediate boss capitulation.

Now, if you want to talk highlighters, this here is the gold standard. Smear Guard ®

I didn't, but thanks for the input.

That bit about "childishly" was a joke.

Labels: , , , , , , ,

Saturday, January 05, 2019

2018 movies

1.  Halloween (2018, David Gordon Green)
2.  Suspiria (2018, Luca Guadagnino)
3.  The Ballad of Buster Scruggs (2018, Joel & Ethan Coen)
4.  The Other Side of the Wind (2018, Orson Welles)
5.  Venom (2018, Ruben Fleischer)
6.  Isle of Dogs (2018, Wes Anderson)
7.  Widows (2018, Steve McQueen)
8.  Lords of Chaos (2018, Jonas Åkerlund)
9.  BlacKKKlansman (2018, Spike Lee)
10. The House That Jack Built (2018, Lars von Trier)

Labels: ,


Took a quick look at the last time I talked about pens, my mind aglow with whirling, transient nodes of thought careening through a cosmic vapor of invention, and had a discomfiting, disconnected moment. I could scarcely recognize the child I was, tho' the child ever is father to the man, nor credit the opinions he expressed.

Particularly alien I found the conclusion, in which 2017 Fat plumped for reaching in the main for the Pilot (Precise) V5. This bears essentially no relation to current practice, preference, or predilection. The (r)evolution has I think more to do with what I'm writing on than what I'm writing with.

(I found this pen in the bag of scissors / tape / pens / etc. I maintain for Xmas-present-wrapping operations. Man, I sure chewed on this one a lot.)

I've been working, with a kind of dogged, halting persistence, to refine my notebook approach, spurred by conditions both material (I have roughly a dozen Field Notes notebooks on hand) and ideological (I love those Field Notes notebooks, and the uniformity of writing things in identical containers drives a certain urge towards tweaking my approach to their filling, until I feel optimized, plus I have watched more than one video about bullet journaling). Details on all that to come. But with a striving towards consistency and perfection must come a desire for sameness—in this case, yoked to an/the ever-present lust for novelty, viz., I saw a new-to-me kind of pen when I was in a stressful situation and (therefore) in need of easeful consumption—and thus came into my life the stirring adequacy of the spartanly named Sharpie®|Pen., whose chubby, softish barrel is bleh at best, but inoffensive, and whose tip and ink please nigh-invariably.

(You may be able to see that the tip is slightly bent, because I dropped it point-down onto a hard floor, almost immediately after starting to use it. This is vaguely reminiscent of using a pencil, and I kind of like it.)

Not as stable a platform as the light carbine of the Le Pen nor the fully functional Batmobile of the Micron ~Art Pen~, it hits much the same marks, but with waterproof ink and a less intimidating mien. I tried to use it exclusively in my most recent notebook, and except for the day I forgot it at work and had to press back into service one of my absolute favorite (green) Le Pens, I succeeded. Pleasing consistency!

That notebook (was) finished last night; the next follows. After a painstaking review of my Pen Situation and my Evolving Habits, I have decided to retire the Sharpie®|Pen. for the duration of that notebook (48 pages, usually around as many days), for reasons I will describe just as soon as they are clear to me.

(These are fine-tipped, 0.8 mm. I wonder what the Ultra Fine experience is like??)

Labels: , , , , , , , ,

Tuesday, November 20, 2018

Getting to Yes

I don't remember where the poster came from, but I remember the blue UFOs hovering over hills with duct-tape loops holding them on the wall, and I remember knowing—but never learning—that it was a painting by Roger Dean. Somehow I knew also that Roger Dean painted album covers for Yes, who at that point I had certainly never heard. The poster lived on one wall or another for a few of the places we lived in in the stretch during which I went to two schools for fourth grade, a third for fifth, a fourth for sixth, and a fifth for seventh.

When the summer ended and I rejoined my parents for (a couple weeks after) the beginning of seventh grade, my uncle, my mom's youngest brother, was living with us. He'd work with me on Frisbee throwing / catching, and I'd sit in his car and listen to his tapes, or the radio, soaking up his thoughts on Don't Stop (drumming on the steering wheel) or Everybody Have Fun Tonight ("everybody Wang Chung tonight") ("This is an anthem!"). I suspect but can not prove that he was the original source of the poster—I know he was the source of my first orange crate of records, turntable, receiver, and speakers; he'd moved out one night, unexpectedly, after a falling out with my mother.

It was 1986. I didn't know much. I knew I'd loved a glowing-blue poster, by a guy who did album covers for Yes.* I knew AC/DC was my favorite band, maybe my favorite thing, I knew my favorite novel was Starship Troopers, with all its powered armor and pointedly problematic patriotism. Flipping through the orange crate, I saw art familiar, friendly to my eyes. I pulled out it, and skimmed song titles, and when I found "Starship Trooper", I knew this is, this has to be, For Me. I knew, before the needle hit the groove, that this would surely crunch harder, punch faster, than anything off of Flick of the Switch.

What I heard was, essentially, early R.E.M. with a more expansive heart: soaring organ, chiming guitars, carefully plucked, and a falsetto opening the song with "Sister bluebird / flying high abo-o-ove".

I was nothing close to prepared for this. I pulled the needle up and off, stuffed the record back in its sleeve, went back to hard rock radio and didn't think about Yes again for close to 20 years, when my girlfriend was out of town, and I had her mom's car so I could dogsit, so (naturally) I went to Best Buy, where I made a joke purchase of Yes' greatest hits...which blew my mind...and then, a few years later, I was at last ready to realize: Yes makes pretty music that makes me happy; sometimes that's what I want.

Now "Starship Trooper" is one of my favorite songs. When the pretty, hopeful, bombastic section (that I'm pretty sure is called "Life Seeker") gives way to the quick-stepping-then-electric "Disillusion" part (probably), with its layered "aaaahhhh" harmonies, that is extremely pleasing and heartening. When everything drops out and phased, flanged guitar carries the day solo for a while, with a hook so irresistable that Love & Rockets would have a huge hit with a song consisting exclusively of it, then building intensity and instrumentation on top of it for long minutes...then the coily solo comes in and combines soaring with the kind of heart-cutting wince of happy pain you feel when you see your crush (or when I see a particularly blocky puppy head), I realize, in as real a way as I can manage: this is church music.

Twenty years ago, when I heard Yes, it repelled me. A few weeks ago, working a strike in a town not my own, lonely (and exhausted, and generically upset / sad) in a hotel room, I paid for a music streaming service I'd used the free version of for years, putting up with mostly awful ads and unable to download anything, subject to data availability and the whims of Wi-Fi. The first thing I downloaded: Fragile.

NOTE: The artist responsible for my poster, and, I think, a few other artifacts from that time that I haven't been able to remember clearly enough to run down, was not Roger Dean. A lot of the things we just know, but maybe can't remember learning, turn out to be not so, later. This may be particularly true with the knowledge of, and imparted by, Record Store Guys.

The artist is Gilbert Williams. The image I loved, I recently learned, was an album cover for Crosby, Stills, and Nash. It probably sold a couple million copies. thing it's important to learn is that a cool thing can be shared. It doesn't have to be just yours. (My copy of the poster did not have any words on it, though. I have to make that clear.)

Labels: , , , , ,

Friday, May 04, 2018

Great Urinals of the Pacific Northwest

Vancover Elks Lodge basement


Wednesday, March 28, 2018

A Comprehensive Review of Alex Garland's Film Annihilation, Compendious in Its Correctness (Also It Is: Indisputable)

Point 1.

Oh, Alex Garland.

Point 2.

Here are some things that are extremely cool.

  • that one episode of X-Files where the scientists in the Arctic discover a creepy worm alien or whatever and the one guy yells "We're not ... who we ARE!"
  • The Thing
  • 2001
  • Alien / Aliens
  • Heart of Darkness / Apocalypse Now / going up a river to where humanity disintegrates

Labels: , , , , , ,

Tuesday, March 27, 2018

Vim (for non-programmers) Part Three: Refactoring my .vimrc File, Chapter Five; Correct Easy Markup of Markdown Headlines (Building on Chris Toomey's "Your First Vim Plugin")

At some point in the quest to have The World's Greatest .vimrc File, a person will naturally begin to explore the wider surround, see what the community is up to on the weird-ass-solutions-to-incredibly-narrow-problems front. Since, sometimes, work, life, and other responsibilities exert their gravitationals* upon a person, one helpful way to perform this exploration is to throw on a YouTube video in the background while waiting for the requiring hordes to get bored waiting for me to do the needful and go bother somebody else. I.e., it can be kind of fun to half-listen to somebody, and sometimes you get interesting hints while you're ostensibly, or even actually, working on something else...

*Read: suck.

A great place to start is with Chris Toomey's "Your First Vim Plugin" talk.

Toomey comes across like a delightful fellow, smart and approachable, and his basic approach to creating a plugin seems exactly right to me:

  • Find a problem (something that's difficult, or time-consuming, or repetitive to do)
  • Figure out a working solution (that is easier, or faster, or that eliminates repetition)
  • Drop it in your .vimrc
  • Tinker with it as you find that it needs improvement
  • Eventually abstract it and pull it out of your .vimrc, if you feel like it or if you feel like sharing it

Since I tend to take a lot of my notes in Markdown**, his Markdown underlining approach really made sense to me: a quick and dirty mapping to make something an H1 headline or H2 headline fits my workflow nicely—particularly after abstracting it a tiny bit so that one mapping, <leader>h1, adds the appropriate headlining markup whether I'm writing HTML or Markdown (which Vim knows because it's smart about filetypes!).

**What's Markdown? For most people, it's a way to write very lightly formatted text that can be submitted to another program, and out is spit nicely formatted HTML or something that looks pretty pasted into a Word doc or something. For me, it's a way to tell Vim "Please treat a raw .txt file like it's something else, including pretty syntax highlighting that makes it easier to see what's what." It looks like so:

Here's Chris Toomey's approach:

:nnoremap <leader>h1 :normal! "yypVr=<esc>"
– in normal mode, ignoring all other mappings
<leader>h1 – when I type the leader key, then h then 1, act like I typed the next line (without quotes)
:normal! "yypVr=<esc>"
yypVr=yy means "yank (copy) the entire line";
p means "put (paste), in this case, the entire line"
V means "visually select (highlight) the entire line"
r= uses the r command followed by another character to mean "replace the character under the cursor with the character typed after r"; in this case, since the entire line has been visually selected, in effect, every character in the line is under the cursor, so every character in the line gets replaced with an equals sign character, which is the Markdown character that makes a headline

It works, it's lightning-fast, and it's completely transparent! I dumped it into my .vimrc immediately, and changed two characters so it would also work for h2 tags (by adding a line of hyphens, not equals signs):

:nnoremap <leader>h2 :normal! "yypVr-<esc>"

This overall approach, in which you come up with a solution that can then be extended, is super congenial to me, and I'm beyond stoked that Toomey put it in front of me. After a while, though, the specific nature of the solution started to bug me a little bit.

The problem was that, at an abstract level, I didn't want to:

Copy a line
Paste a copy of the line beneath the first line
Replace all the characters in the second line with a Markdown markup character

What I wanted to do was:

Given a certain line
Create a line underneath it
With as many markdown markup characters as the given line had characters (including tabs or whatever) so it looks pretty

So I set about trying to make something that would do those things.

Oddly, I succeeded. Here's how it went down.

Vim's built-in programming language, VimScript, has a big library of built-in functions, some of which interact with text. You can check them out at :help functions and :help function-list. After poking around in them and fiddling around getting frustrated for a while, I was able to write the following one-liner, which did exactly what I wanted:

:call append(".", repeat("=", strdisplaywidth(getline("."))))

Let's read that from the inside out:

getline(".") is a function that fetches a line in the current buffer (read buffer for our purposes as "the file we're working on"); what goes in the parentheses is the line number, and "." is the wildcard that means "the line the cursor is on"
strdisplaywidth() is a function that looks at a string and tells you how wide it is, in characters displayed on the screen – including tabs and what have you. The trick with this function is that it can take as its argument another function; put the two functions together as we have, and it means "get the line under the cursor, then tell me how long it is"
repeat("=", 68) is trickier: the way the help describes it as a generic function is repeat({expression}, {count}), which means "do the {expression}, which is the thing inside quotes and before the comma, a number of times specified in {count}". Here I've told it that the expression is the equals sign, which is the character we use in Markdown to underline something that's a headline, and I've yet again fed it, instead of a number, the result of a function, our earlier "get the line under the cursor, then tell me how long it is"
append(".", {text}) is a bit of an easier one by now. append()'s arguments say "after a specified line, insert {text}". Here, we re-use the "." wildcard to specify that the line we want to start with is the line under the cursor, and the text we want to be inserted is the result of the repeat("=", strdisplaywidth(getline(".))) series of functions. Simple!

I can do this any time just by putting the cursor on the line I want and typing:
:call append(".", repeat("=", strdisplaywidth(getline("."))))

That's a lot of relatively persnickety typing to have to do, though. The approach I took was what I take to be a relatively common one, but one that I may very well be misunderstanding! What I did was:

  1. Wrapped the 'sucker in a (script-specific) function of my own
  2. Defined a special command to call the function
  3. Made a mapping that will call that command when I'm writing Markdown, but will call a different command when I'm writing something else

What I may be misunderstanding is why exactly I needed my own function. It seems to simplify using the same mapping to call a variety of different commands, but it may be an unneeded step. Anyway, as it lives in my .vimrc file, it looks like the following:

function! s:MarkdownHeadline1()
:call append(".", repeat("=", strdisplaywidth(getline("."))))
command! MarkdownHeadline1 call s:MarkdownHeadline1()

function! s:MarkdownHeadline2()
:call append(".", repeat("-", strdisplaywidth(getline("."))))
command! MarkdownHeadline2 call s:MarkdownHeadline2()

function! s:MakeHeadlines()
if &filetype == 'markdown'
echo "Markdown!"
" :nnoremap h1 yypVr=
:nnoremap h1 :MarkdownHeadline1
" :nnoremap h2 yypVr-
:nnoremap h2 :MarkdownHeadline2
:nnoremap li I-
" other stuff elided for clarity
command! MakeHeadlines call s:MakeHeadlines()

The MakeHeadlines() function is growing, slowly, and as I get it to do more stuff that I want it to do, it's slowly outgrowing its little name. By the time I'll abstract it into something more broadly useful and extract it into a real plugin, not just a chunk of code sitting in my .vimrc file, I will rename it "Corduroy."

Previous entries in Vim (for non-programmers):

Image yoinked from: