{"id":908,"date":"2018-03-25T08:47:49","date_gmt":"2018-03-25T12:47:49","guid":{"rendered":"http:\/\/wcarss.ca\/log\/?p=908"},"modified":"2018-04-24T15:32:44","modified_gmt":"2018-04-24T19:32:44","slug":"searching-for-special-chars-in-vim-and-setting-aliases-in-windows-cmd","status":"publish","type":"post","link":"https:\/\/wcarss.ca\/log\/2018\/03\/searching-for-special-chars-in-vim-and-setting-aliases-in-windows-cmd\/","title":{"rendered":"searching for special chars in vim and setting aliases in windows cmd"},"content":{"rendered":"<h2>Vim Spells<\/h2>\n<p>This morning I was looking over the old reading list and noticed that <a href=\"http:\/\/wcarss.ca\/reading\/fiction\/lonesome_october\/\">A Night in the Lonesome October<\/a> had some strange characters floating around, which I wanted to delete. I felt that deleting them all using vim&#8217;s search\/delete seemed like a good plan, but I couldn&#8217;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 &#8212; ahoy, to the internet!<\/p>\n<p>This <a href=\"https:\/\/stackoverflow.com\/questions\/2312844\/vim-yank-into-search-register\">stackoverflow question<\/a> had exactly what I needed in one answer, and then a great improvement right after. The initial\u00a0solution is to <a href=\"https:\/\/stackoverflow.com\/a\/2312897\">yank into a letter-named register<\/a> using <code>\"ayw<\/code> (<code>\"<\/code> = specify that a register name follows, <code>a<\/code> = overwrite the &#8216;<code>a<\/code>&#8216; register, <code>y<\/code> = yank, <code>w<\/code> = a word, so all together that command says &#8220;yank a word into register <code>a<\/code>&#8221; &#8212; you could also use, say, <code>\"ayy<\/code> to yank a line, etc), and then to use <code>CTRL-R<\/code> followed by the register (in this case, <code>a<\/code>) 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 <a href=\"https:\/\/stackoverflow.com\/a\/18589274\">use the implicitly-filled &#8216;<code>0<\/code>&#8216; register<\/a>, so you can just, say, <code>yw<\/code> as normal to yank a word, and then use <code>CTRL-R 0<\/code> to pull from the <code>0<\/code> register which got filled implicitly by the yank command.<\/p>\n<p>I also didn&#8217;t quite remember what the command-mode string to delete a line matching a pattern was. I tried <code>:%d\/search term\/<\/code> first, but I only got trailing-characters-errors as a result, so I turned back to the internet. Google quickly turned up this <a href=\"http:\/\/vim.wikia.com\/wiki\/Delete_all_lines_containing_a_pattern\">vim\u00a0wikia tip<\/a> that it&#8217;s <code>%g\/search term\/d<\/code>. <code>%g<\/code> to globally search and execute a command on matching lines, and <code>\/d<\/code> to specify <code>delete<\/code> as the command to be issued.<\/p>\n<p>I haven&#8217;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&#8217;ll remember these pieces a bit better next time and cut Google out of the loop.\u00a0\ud83d\ude00<\/p>\n<h2>Windows CMD Aliases<\/h2>\n<p>In a mildly different zone of computer use, I was missing a few of my common command-line aliases in the windows shell, <code>cmd<\/code>. I tend to use &#8216;<code>s<\/code>&#8216; for <code>git status<\/code>, &#8216;<code>d<\/code>&#8216; for <code>git diff<\/code> to see the unstaged changes, and &#8216;<code>c<\/code>&#8216; for <code>git diff --cached<\/code> to see what&#8217;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.<\/p>\n<p>Thankfully, the god-emperor of the internet Google quickly served up <a href=\"https:\/\/stackoverflow.com\/questions\/20530996\/aliases-in-windows-command-prompt\">this fine stackoverflow<\/a>, which listed a few interesting options:<\/p>\n<ol>\n<li><code>doskeys<\/code> in an <code>alias.cmd<\/code> that gets <a href=\"https:\/\/stackoverflow.com\/a\/20531778\">loaded via the shell shortcut with <code>\/K<\/code><\/a><\/li>\n<li><code>doskeys<\/code> in an <code>alias.cmd<\/code> that gets <a href=\"https:\/\/stackoverflow.com\/a\/21040825\">loaded via a registry key<\/a><\/li>\n<li><code>.bat<\/code> files in an aliases folder that <a href=\"https:\/\/stackoverflow.com\/a\/39459404\">you add to your <code>PATH<\/code><\/a>.<\/li>\n<\/ol>\n<p>These are <strong>all<\/strong> pretty cool ideas! I was only vaguely aware of <code>doskeys<\/code> before reading this post, so that&#8217;s a keeper at the least.<\/p>\n<p>After some thought, I opted for the registry editing route &#8212; here&#8217;s why:\u00a0I use at least 2 shortcuts to open <code>cmd<\/code>, and I don&#8217;t want to have to modify the launch string in both. Moreover, I definitely don&#8217;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&#8217;t fit my needs. The <code>.bat<\/code>-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 <code>.bat<\/code> for each of them seems like overkill.<\/p>\n<h2>Over 1 Billion Yaks Shaved<\/h2>\n<p>All of this is, as usual, procrastination. I&#8217;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 <a href=\"https:\/\/subsetgames.com\/itb.html\">Into the Breach<\/a> that fuses in some more <a href=\"https:\/\/en.wikipedia.org\/wiki\/Advance_Wars\">Advance Wars<\/a>-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 <a href=\"https:\/\/github.com\/wcarss\/tetris\">tetris<\/a> (<a href=\"http:\/\/wcarss.ca\/tetris\">playable link<\/a>) work on <a href=\"https:\/\/github.com\/wcarss\/creek\">creek<\/a> into creek itself before I go spawning new projects like baby spiders in the wind.<\/p>\n<p>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.<\/p>\n<p>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!<\/p>\n<p>update: fixed! Configuring nginx for wordpress just took me a lot of reading and trial and error. \ud83d\ude00<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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&#8217;s search\/delete seemed like a good plan, but I couldn&#8217;t recall a way to copy the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/wcarss.ca\/log\/wp-json\/wp\/v2\/posts\/908"}],"collection":[{"href":"https:\/\/wcarss.ca\/log\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wcarss.ca\/log\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wcarss.ca\/log\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wcarss.ca\/log\/wp-json\/wp\/v2\/comments?post=908"}],"version-history":[{"count":24,"href":"https:\/\/wcarss.ca\/log\/wp-json\/wp\/v2\/posts\/908\/revisions"}],"predecessor-version":[{"id":935,"href":"https:\/\/wcarss.ca\/log\/wp-json\/wp\/v2\/posts\/908\/revisions\/935"}],"wp:attachment":[{"href":"https:\/\/wcarss.ca\/log\/wp-json\/wp\/v2\/media?parent=908"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wcarss.ca\/log\/wp-json\/wp\/v2\/categories?post=908"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wcarss.ca\/log\/wp-json\/wp\/v2\/tags?post=908"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}