Found Laying Around the Shop

Monday, July 12, 2021

Vim (for non-programmers) Volume Four Hundred and a Score: stone by stone, brick by brick

Swopped out work laptops earlier this year, and for reasons involving ignorance ("back up your dotfiles to GitHub" means as much to me as it does to Emily Fusselman's rabbit) and laziness I have not had the advantage of my fully functioning battle station set of tweaks for some months now. Over the past few days, though, I've had a felt need for some new functionality, and, having achieved this, I took on an old challenge I had never quite cracked.

I shall treat of these in turn.

I've been doing a lot more in Markdown lately, and while taking notes during a training on returning to office work in a COVID-19 environment1 I realized that, for note-taking purposes and later reference, Markdown's reference links make lots more sense for a readable document than in-line HTML-style links.

Per the documentation, inline links look like:
This is an [example in-line link](https://examplelink.org) in a sentence people are trying to read

Reference links look like:
This is the [first example reference link][1] and this is the [second example reference link][2].
[1]: https://examplelink.org
[2]: https://secondexamplelink.org

It's more readable! I like that. I like to read. :) So I wanted to figure out how to make it faster and easier. You may remember that my old link-adding techniques looked like:
Add Link to Word the Cursor Is On
" make the word under the cursor a hyperlink to URL from system clipboard
" 18jan2016
" mapping <leader>a to:
" select the current word with viw
" wrap the current word in an <a href> tag
" by moving to the end of the word and adding <a> to close the tag
" then moving to the beginning of the WORD and adding <a href="">
" moving back to the beginning of the WORD to move to the quotes
" and populate the quotes with the contents of the + register
" mostly inspired by Steve Losh
" edited 27dec2016
" :nnoremap <leader>a viw<esc>a</a><esc>Bi<a href=""><esc>Bci"<esc>a<c-r>+<esc>
:nnoremap <leader>a viw<esc>a</a>Bi<a href="<c-r>+<esc>a"><esc>


Add Link to Last Thing That Was Visually Selected
" make the last visually selected text a hyperlink to URL from system clipboard
" 18jan2016
" mapping <leader>v to:
" select the last visual selection with `< and `>
" wrap that selection in an <a href> tag
" by moving to the end of the visual selection and adding </a> to close the tag
" then moving to the beginning of the visual selection and adding <a href="">
" moving back to the beginning of the visual selection to move to the quotes
" and populate the quotes with the contents of the + register
" mostly inspired by Steve Losh
:nnoremap <leader>v `>a<a><esc>`<i<a href=""><esc>Bci"<esc>a<c-r>+<esc>

The needs of the Markdown style of reference link are slightly different, however, so the approach I landed on was the following:
Add Reference Link to Last Thing That Was Visually Selected
" add a reference link in Markdown
:nnoremap <leader>rl <esc>gvI[<esc>A][]<esc>

This will need at some point some editing to append to the bottom of the file and add the actual links, etc., but I'm not quite there yet.

I've also long struggled with automating / streamlining making things bullets in Markdown, as well. The most common use case for making things bullets that weren't bullets as I was originally typing things in involves marking up previously typed things that I've visually selected. Luckily, the modal editor paradigm allows this to work with a subtle change in the mapping: it turns out a person can remap visual mode key combinations just as she can remap normal mode key combinations. Fiddling around with this this week, I landed on:
" add bullet format to visual selection
:vnoremap <leader>- <esc>gv:s/^/ - /<enter>
:vnoremap <leader>* <esc>gv:s/^/ * /<enter><esc>V>

Then, when I started dinking around with consolidating all this, I realized I had this already floating around:
:nnoremap <leader>li I- <esc>
:nnoremap <leader>ld 0V><esc>f-r*

This latter solves the problem that, often, what I need to do automatically is indent an existing bullet...but, obviously I didn't use it enough to remember that I'd created it.

But! As a bonus, I'd always had the problem—particularly when working on my .vimrc file—of wanting, even needing, to comment out a bunch of lines that I'd visually selected. For some reason, this never clicked until recently, when I realized this operation is more or less trivial:
:vnoremap <leader>c <esc>gv:s/^/" /<enter>

I have in the works a way to abstract that key combination to insert comments by filetype (HTML, Python, VimScript) but it's not super pressing, and the mechanics are basically transparent, so I can leave the details as an exercise for the (likely purely hypothetical, at this point) reader.

—Fat, trying to remember to sharpen his saw

1 Shut up, I'm a union steward, taking notes on things bosses say is kind of my thing.

Sunday, July 11, 2021

C'mon you know you think the white catsuit is cool


What sets Black Widow (2021, Cate Shortland) apart from all the other Marvel Studios movies? Well, being a blockbuster featuring one of the few Avengers with no discernable super powers, it relies on what the other current big summer movies sell: gravity-defying set pieces where people, vehicles, and air craft ultimately transport us into what a kid’s imagination does with their toys. I always wondered what Black Widow’s super power was, and this movie taught me that it’s being able to walk away from the worst wrecks without a scratch (just like the Marvel brand itself). 

     Black Widow also maintains a policy wherein shots are framed from angles that never let us forget that Scarlett Johansson has a nice butt (notice how the poster illustrates the BW logo is a graphic symbolizing her hourglass figure).  And because it’s Hollywood, there’s also the obligatory 12 years younger Florence Pugh sent in to replace her. YELENA (Pugh) gets the best lines: “This would be a really cool way to die,” and “You’re such a poser,” too. And YELENA has the Marvel sarcasm down wonderfully. It’s really Pugh’s movie. She’s amazing.

     Along with the TV series that have been airing on Disney +, Black Widow observes the politics of representation that Phase IV mandates. Black Widow pits the sisters against TASKMASTER—a masked super solider who is revealed in the third act to be played by Olga Kurylenko. And under the mask her face has been badly scarred. So how do you think they will defeat this disfigured but still beautiful, powerful woman with what I think casting agents might call an “ethnic” look? Hint: her boss is a rich, powerful white male (played by Ray Winstone) who controls a cadre of racially and ethnically diverse young women from impoverished backgrounds. 

     Another thing about TASKMASTER is that her superpower is mirroring the fighting style of the person she’s fighting. It occurred to me that this is really funny because it explains why the fight scenes in Black Widow look like the exact same choreographed stunt fights in every other Marvel movie.

     In closing, I mean, don’t take my comments as being too cynical. As a big summer action movie, Black Widow goes hard, is fun, and at its heart is basically taking the best from what John Woo was doing in Hong Kong in the late 80s. Don’t all big super hero/spy/military/special ops/international assassin/Fast saga action movies all blend into the same genre nowadays anyway?

 

7/11/2021 AMC Madison Yards 8

Atlanta, GA

DCP