Vim Spells
This morning I was looking over the old reading list and noticed that A Night in the Lonesome October had some strange characters floating around, which I wanted to delete. I felt that deleting them all using vim’s search/delete seemed like a good plan, but I couldn’t recall a way to copy the line containing the special character from the text buffer over into the command-mode search/replace/delete string. I wanted to do it without using my mouse or shell, and knew there must be a way — ahoy, to the internet!
This stackoverflow question had exactly what I needed in one answer, and then a great improvement right after. The initial solution is to yank into a letter-named register using "ayw
("
= specify that a register name follows, a
= overwrite the ‘a
‘ register, y
= yank, w
= a word, so all together that command says “yank a word into register a
” — you could also use, say, "ayy
to yank a line, etc), and then to use CTRL-R
followed by the register (in this case, a
) to paste from the register straight into a command-mode string. The followup that improves this in general use is to avoid named registers and use the implicitly-filled ‘0
‘ register, so you can just, say, yw
as normal to yank a word, and then use CTRL-R 0
to pull from the 0
register which got filled implicitly by the yank command.
I also didn’t quite remember what the command-mode string to delete a line matching a pattern was. I tried :%d/search term/
first, but I only got trailing-characters-errors as a result, so I turned back to the internet. Google quickly turned up this vim wikia tip that it’s %g/search term/d
. %g
to globally search and execute a command on matching lines, and /d
to specify delete
as the command to be issued.
I haven’t ever really used registers in vim, so this is one more of those thousand steps up the mountain in my ongoing (decade-plus-long) vim user story. These are such arcane tools, but at least when you get them to do the work you want, it does still feel like wizardry. With luck, I’ll remember these pieces a bit better next time and cut Google out of the loop. 😀
Windows CMD Aliases
In a mildly different zone of computer use, I was missing a few of my common command-line aliases in the windows shell, cmd
. I tend to use ‘s
‘ for git status
, ‘d
‘ for git diff
to see the unstaged changes, and ‘c
‘ for git diff --cached
to see what’s staged to commit. I have some simple alias commands in most of my unix home dirs, but recalled windows being a bit stubborn here last I looked.
Thankfully, the god-emperor of the internet Google quickly served up this fine stackoverflow, which listed a few interesting options:
doskeys
in analias.cmd
that gets loaded via the shell shortcut with/K
doskeys
in analias.cmd
that gets loaded via a registry key.bat
files in an aliases folder that you add to yourPATH
.
These are all pretty cool ideas! I was only vaguely aware of doskeys
before reading this post, so that’s a keeper at the least.
After some thought, I opted for the registry editing route — here’s why: I use at least 2 shortcuts to open cmd
, and I don’t want to have to modify the launch string in both. Moreover, I definitely don’t want the potential to forget to modify one or to end up with different launch strings in different places, so the shortcut-editing answer didn’t fit my needs. The .bat
-files-in-a-dir solution is aimed at reducing the computer-load of repeatedly loading all your aliases, and I only have 3 simple ones to add for now. On top of that, a .bat
for each of them seems like overkill.
Over 1 Billion Yaks Shaved
All of this is, as usual, procrastination. I’m in Paris for a few weeks and taking a few grey morning hours ostensibly to look at making start on a javascript clone of Into the Breach that fuses in some more Advance Wars-esque ideas (resources, construction, territory, different map sizes) and I need to a) break that problem up a bunch, which is hard, and b) sanely upstream all of my tetris (playable link) work on creek into creek itself before I go spawning new projects like baby spiders in the wind.
Those are daunting tasks. So instead of working on them, I chose to give the world yet another blogpost with a few links deep into the stackoverflow hivemind.
I also noticed that viewing individual blogposts seems to have grown some content-type issues after the migration I did a few weeks back, so I might have to fix that before I do anything else. The procrastination show must go on!
update: fixed! Configuring nginx for wordpress just took me a lot of reading and trial and error. 😀