/images/logo.png

Normal Mode

iVimClippy

Because vimclippy is a shell command, iVim users may fear they are OUT OF LUCK when it comes to FAST clipboard-editing, and that they are doomed to forever tapping out "*P:%y* like NEANDERTHALS.

But there is a way.

Step 1: Create a User-Defined Command

First we’re going to set up a :VimClippy Ex command to insert the current content of the clipboard into a buffer and set up the autocommand to write the edited text back into the clipboard when the buffer is saved.

Batch Editing Files with Vim

Waaay back in 2018, Julia Evans wrote this terrific post about how to edit a BUNCH of files by writing a little ed script. You should absolutely go read the whole post where she explains how to use ed to perform a sequence of edits she’d normally do in Vim.

I just want to add the note that the code she ends up with is also perfectly valid Vimscript. So you can run the EXACT same script in Vim!

Not a Recursive Macro

When I first started my plan to concoct a classically recursive macro, I got as far as writing a complete, functioning implementation before I stopped to think and realised that what I’d been working on wasn’t actually a recursive algorithm at all but was in fact iterative. 🤦

But even though the macro below doesn’t actually fulfil the brief, I’m still kind of proud of the method I came up with for incrementing and testing the loop index, so I thought I’d post it here for posterity.

Extract Variable Mini Refactor with CTRL-A

Insert mode’s CTRL-A was one of those Vim features that I knew about for ages but didn’t get the point of until someone showed me this ONE WEIRD TRICK1 that uses it to ASTONISHING effect2. I added it to my toolkit, and after a while found myself using CTRL-A in loads of other scenarios too!

The :help for CTRL-A in insert mode is… shall we say… concise:

CTRL-A      Insert previously inserted text.

vimclippy

There used to be a nifty Mac utility called QuickCursor. It set up a global hotkey you could use whenever you were editing text in any app. When invoked, it would open up a copy of your chosen text editor1 passing the text into it. You could then edit away using the FULL POWER of your editing setup, and when you saved the file the text would be copied back into the app where it came from.