<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Brett Terpstrakeyboard - Brett Terpstra</title>
	<atom:link href="http://brettterpstra.com/tag/keyboard/feed/" rel="self" type="application/rss+xml" />
	<link>http://brettterpstra.com</link>
	<description>Elegant solutions to complex problems.</description>
	<lastBuildDate>Thu, 09 Feb 2012 15:01:27 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>KeyBindings: new, improved “surround” commands</title>
		<link>http://brettterpstra.com/keybindings-new-improved-surround-commands/</link>
		<comments>http://brettterpstra.com/keybindings-new-improved-surround-commands/#comments</comments>
		<pubDate>Tue, 15 Nov 2011 14:30:10 +0000</pubDate>
		<dc:creator>Brett</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[keybindings]]></category>
		<category><![CDATA[keyboard]]></category>
		<category><![CDATA[os x]]></category>

		<guid isPermaLink="false">http://brettterpstra.com/?p=3186</guid>
		<description><![CDATA[<p>As the next part in the keybindings series I’m demonstrating some improvements I’ve made to the original “surround” commands since my first time around. This set of commands is designed to wrap selected text in a variety of paired characters. The keys are the same, but the commands now work inside of single-line text fields (like you often find in&#8230;</p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/keybindings-new-improved-surround-commands/">KeyBindings: new, improved “surround” commands</a></p>]]></description>
			<content:encoded><![CDATA[<p><img style=' display: block; margin-right: auto; margin-left: auto;'  src="http://cdn2.brettterpstra.com/wp-content/uploads/2011/11/Apple-Keyboard-Header-Image.jpg?9d7bd4" alt="Post header keyboard image" title="Apple-Keyboard-Header-Image" width="650" height="200" class="aligncenter size-full wp-image-3126" /></p>

<p>As the next part in the keybindings series I’m demonstrating some improvements I’ve made to the original “surround” commands since my <a href="http://brettterpstra.com/keybinding-madness/">first time around</a>. This set of commands is designed to wrap selected text in a variety of paired characters. The keys are the same, but the commands now work inside of single-line text fields (like you often find in Safari), prevent auto-pairing in apps like nvALT, MultiMarkdown Composer and Byword, and a few refinements to cursor positioning.</p>

<p><span id="more-3186"></span></p>

<p>Here’s the code to drop into ‘DefaultKeyBinding.dict’, located at <code>~/Library/DefaultKeyBinding.dict</code> (create the folder and/or the file if you don’t have one<sup id="fnref:2"><a href="#fn:2" rel="footnote">1</a></sup>):</p>

<pre><code>  "^@s" = {   // surround commands
    // wrap () with spaces
    "(" = (delete:, insertText:, "( ", yank:, insertText:, " ", moveLeft:, insertText:, " )", deleteForward:);
    // wrap () no spaces
    ")" = (delete:, insertText:, "( ", deleteBackward:, yank:, insertText:, " ", moveLeft:, insertText:, ")", deleteForward:);
    // wrap [] with spaces
    "[" = (delete:, insertText:, "[ ", yank:, insertText:, " ", moveLeft:, insertText:, " ]", deleteForward:);
    // wrap [] no spaces
    "]" = (delete:, insertText:, "[ ", deleteBackward:, yank:, insertText:, " ", moveLeft:, insertText:, "]", deleteForward:);
    // wrap {} with spaces
    "{" = (delete:, insertText:, "{ ", yank:, insertText:, " ", moveLeft:, insertText:, " }", deleteForward:);
    // wrap {} no spaces
    "}" = (delete:, insertText:, "{ ", deleteBackward:, yank:, insertText:, " ", moveLeft:, insertText:, "}", deleteForward:);
    // wrap &lt;&gt; with spaces
    "&lt;" = (delete:, insertText:, "&lt; ", yank:, insertText:, " ", moveLeft:, insertText:, " &gt;", deleteForward:);
    // wrap &lt;&gt; no spaces
    "&gt;" = (delete:, insertText:, "&lt; ", deleteBackward:, yank:, insertText:, " ", moveLeft:, insertText:, "&gt;", deleteForward:);
    // wrap single quotes
    "'" = (delete:, insertText:, "' ", deleteBackward:, yank:, insertText:, " ", moveLeft:, insertText:, "'", deleteForward:);
    // wrap backticks
    "`" = (delete:, insertText:, "` ", deleteBackward:, yank:, insertText:, " ", moveLeft:, insertText:, "`", deleteForward:);
    // wrap double quote
    "\"" = (delete:, insertText:, "\" ", deleteBackward:, yank:, insertText:, " ", moveLeft:, insertText:, "\"", deleteForward:);
  };
</code></pre>

<p><strong>Key:</strong> ^=control, @=command</p>

<p>The whole set is bound to Control-Command-S, so you use them by:
* selecting some text that needs quotes, parenthesis, brackets, etc. wrapped around it
* press Control-Command-S
* typing the key you want to wrap the text in</p>

<p>It’s set up to handle parenthesis, square brackets, angle brackets, curly brackets, single/double quotes and backticks. In the parenthesis and brackets, typing the left character of the pair adds the wrapping with spaces on the inside of the pair (e.g. <code>( text I wrapped )</code>) and the right character wraps with no spaces (e.g. <code>(text I wrapped</code>)).</p>

<p>If you just want one or two and don’t need them bundled in the Control-Command-S wrapper, you can always extract them from that section of the plist and move them into the root. Because we’re just wrapping and not autopairing, the commands make more sense (to me) with a hotkey to enable them.</p>

<p>If you don’t have a selection when you run these, it’s going to insert the last thing it “yanked” and you never know what you’ll get. The yank pasteboard is separate from the main pasteboard, so it has little to do with what you intentionally copied last. If you’re using these keybindings, it will likely contain the last selection you ran one of them on.</p>

<p>Just for edification, let’s dissect one, shall we? Here’s the binding for wrapping in double quotes, made a little prettier for readability:</p>

<pre><code>// wrap double quote
"\"" = (    delete:, 
            insertText:, "\" ", 
            deleteBackward:, 
            yank:, 
            insertText:, " ", 
            moveLeft:, 
            insertText:, "\"", 
            deleteForward:, 
    );
</code></pre>

<ul>
<li>In the first three line delete the selection. The text is now in our yank pasteboard.</li>
<li>Then we insert the text “\” “

<ul>
<li>The backslash escapes the double quote so it doesn’t break the surrounding quotes in the plist</li>
<li>The trailing space fools most auto-pairing setups into not inserting the right-side pairing automatically. We immediately delete backward to remove the extra space</li>
</ul></li>
<li>Next, we use the “yank:” method to put back the text we originally cut out and insert a space immediately after it. The space allows us to manipulate the end of the text without hitting the end of the line, as would happen in certain editors and always in single-line text fields.</li>
<li>We move left past the new space and insert the closing quote</li>
<li>Finally, we delete to the  right remove the trailing space</li>
</ul>

<p>We want the cursor to end up after the last character of the wrapped text, so we can just stop there.</p>

<p>Hopefully that gives you enough ammo to start coming up with more, and enough of a taste to help you realize that this is seriously the most powerful text tool in your arsenal. It’s application agnostic, completely customizable and totally free. Have fun.</p>

<p>For my full DefaultKeyBinding.dict file, check out the <a href="https://github.com/ttscoff/KeyBindings">GitHub repo</a> and feel free to steal/fork mine. I’ll continue posting and describing pieces of it, but if you’re impatient and know how to read it already, go for it.</p>

<div class="footnotes">
<hr />
<ol>

<li id="fn:2">
<p>If you’re creating a new DefaultKeyBinding.dict file, be sure to add a pair of curly brackets ({}) in the blank file and insert any new bindings between them. <a href="#fnref:2" rev="footnote">↩</a></p>
</li>

</ol>
</div>
<p>Related posts:<ol>
<li><a href='http://brettterpstra.com/keybinding-madness/' rel='bookmark' title='KeyBinding madness'>KeyBinding madness</a></li>
<li><a href='http://brettterpstra.com/the-keys-that-bind-keybinding-madness-part-2/' rel='bookmark' title='The keys that bind: KeyBinding Madness part 2'>The keys that bind: KeyBinding Madness part 2</a></li>
<li><a href='http://brettterpstra.com/a-little-keybinding-sanity/' rel='bookmark' title='A little KeyBinding sanity'>A little KeyBinding sanity</a></li>
</ol></p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/keybindings-new-improved-surround-commands/">KeyBindings: new, improved “surround” commands</a></p>]]></content:encoded>
			<wfw:commentRss>http://brettterpstra.com/keybindings-new-improved-surround-commands/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Byword for keyboard nerds</title>
		<link>http://brettterpstra.com/byword-for-keyboard-nerds/</link>
		<comments>http://brettterpstra.com/byword-for-keyboard-nerds/#comments</comments>
		<pubDate>Mon, 07 Nov 2011 13:30:56 +0000</pubDate>
		<dc:creator>Brett</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[keyboard]]></category>
		<category><![CDATA[markdown]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[text]]></category>

		<guid isPermaLink="false">http://brettterpstra.com/?p=3120</guid>
		<description><![CDATA[<p>When it comes to keyboard navigation, Vim impresses the hell out of me, but TextMate keyboard shortcuts take up more of my muscle memory than any other app. I’m sure anyone who’s used any IDE for a while has their share of keyboard chops and preferences. Even in the graphics world, you are absolutely not considered a Photoshop pro until&#8230;</p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/byword-for-keyboard-nerds/">Byword for keyboard nerds</a></p>]]></description>
			<content:encoded><![CDATA[<p><img style=' display: block; margin-right: auto; margin-left: auto;'  src="http://cdn2.brettterpstra.com/wp-content/uploads/2011/11/Apple-Keyboard-Header-Image.jpg?9d7bd4" alt="Post header keyboard image" title="Apple-Keyboard-Header-Image" width="650" height="200" class="aligncenter size-full wp-image-3126" /></p>

<p>When it comes to keyboard navigation, Vim impresses the hell out of me, but TextMate keyboard shortcuts take up more of my muscle memory than any other app. I’m sure anyone who’s used <em>any</em> IDE for a while has their share of keyboard chops and preferences. Even in the graphics world, you are absolutely <strong>not</strong> considered a Photoshop pro until you’ve learned at least 36 keyboard shortcuts.</p>

<p>Today, though, I want to point out a few keyboard shortcuts in a place you might not expect to find them: the plain text editing side of <a href="http://brettterpstra.com/app-review-byword/">one of my favorite</a> writing tools, <a href="http://bywordapp.com/">Byword</a>.</p>

<p><em>Note: I have a lot of <a href="http://brettterpstra.com/keybinding-madness/">custom, system-level keybindings</a> for writing Markdown, so if I say something and you try it and it’s just not there, let me know. Though not likely, I might mix up my own hacks with Byword’s actual features.</em></p>

<p><span id="more-3120"></span></p>

<h3>Byword keyboard shortcuts for fun and profit</h3>

<p>First off, there’s a very handy shortcut for increasing and decreasing the scope of a text selection. <strong>Command-Option-Up Arrow</strong> will expand your selection in both directions, selecting the closest word to the right of the caret<sup id="fnref:caret"><a href="#fn:caret" rel="footnote">1</a></sup>, or the current word if the caret is inside a word. Press it again and the sentence containing the word is selected. Unlike advanced text editors, it’s not aware of scopes, so it doesn’t stop between encompassing quotes or brackets, but for most writing purposes, this is just fine. Pressing it again will select the paragraph you’re working on. One more and you’ll select the whole document. At any point after expanding the selection, you can reduce it back to the next level with <strong>Command-Option-Down Arrow</strong>.</p>

<p>That’s super-handy, but it gets cooler.</p>

<h3>Moving and sorting</h3>

<p><em>Alternate section heading: “So much help with sorting and moving that you’ll have to buy them a 6-pack at the end of the day.” That one got a bit long.</em></p>

<p>It’s also worth pointing out the text movement shortcuts. The first handy one is <strong>Control-Command-Up/Down Arrow</strong>. This moves selected text up and down by lines. If you have a selection in the middle of a line, it will remove that selection from the line and put it above or below (depending on which arrow key you hit). You can reorganize paragraphs very easily with the first selection shortcut I mentioned and then some <strong>Control-Command-Up/Down</strong> action.</p>

<p>The real beauty of this text movement shortcut, though, is in Markdown list editing. <strong>Command-Option-Up-Up</strong> will select the full line of the list item your caret is in, and then you can use <strong>Control-Command-Up/Down</strong> to re-order items. It’s so much faster than copy/paste that it hurts just to think about doing it that way. Guess what? It works for indentation, too. You can indent and outdent with <strong>Control-Command-Left/Right</strong>. Not just lists, either. It works well on paragraphs and blockquotes, and is especially handy for tabbing a block of code (or poetry) in for Markdown formatting.</p>

<h3>More Markdown List Love</h3>

<p>Lastly, jumping back to Markdown lists for a moment… You may know <strong>Command-L</strong> is a shortcut for starting a bullet list. It will also instantly turn an existing line of text into bulleted list item, and you can run it from any point in the line without making a selection. Hitting return from the end of that line will automatically continue a list. You can also run it on any series of lines to turn every line break into a new list item all at once (blank lines will become blank list items, it doesn’t compress whitespace). You can also run it on a line that’s already a list item to remove the bullet, again without selecting anything.</p>

<p>Of course, you can do the same for numbered lists with <strong>Command–<em>Option</em>–L</strong>, same behavior across the board. Quickly create your lists–bullet, numbered or nested–reorder them with the text movement shortcuts and then you’ll come to my favorite of the list commands: <strong>Command-Shift-L</strong> converts lists between bullet and numbered.</p>

<h3>Extensive elaboration on why I love ⌘⇧L</h3>

<p>It’s not my favorite because I use it often, but because it’s one feature that I only ever see in the most well thought-out Markdown editors. <a href="http://fletcherpenney.net/">Fletcher</a> put it into the original MultiMarkdown TextMate bundle (and I expect it will be incorporated into <a href="http://multimarkdown.com/">MultiMarkdown Composer</a>, eventually).</p>

<p>Anyway, you put the caret on any line of your list, type <strong>Command-Shift-L</strong> and every list item at that level gets toggled between numbered and bulleted. It’s smart, too. If you’re operating on an indented line that’s part of a nested list, it will only affect the items in that section of the list. If you run it on a root-level item, it won’t affect any sub-lists, only converting the root items.</p>

<p>Additionally, <strong>Command-Shift-L</strong> re-sequences the numbers when converting to numerical format, making it a breeze to re-build your lists after doing some of that speedy sorting I was talking about earlier. It also comes in handy when creating the list: you start a bulleted list, and then <strong>Control-Command-Right</strong> to indent the list item and hit <strong>Command-Shift-L</strong> to switch to numbers, and when you finish the nested list, outdenting and switching back to bullets is two key-combinations away.</p>

<p>When it toggles the type, it intelligently handles converting mismatches, too, turning a mix of numbers and asterisks first into a properly ordered numbered list and then toggles the whole thing to bullets on a repeat keypress.</p>

<p>That was a whole section about one keyboard shortcut, sorry. I just have a strong appreciation for really thoughtful developers and features like this<sup id="fnref:nvalt"><a href="#fn:nvalt" rel="footnote">2</a></sup>. There are more keyboard shortcuts in Byword, just browse through the menu system!</p>

<h3>I love you, man</h3>

<div id="attachment_3124" class="wp-caption alignright" style="width: 340px;  border: 1px solid #dddddd; background-color: #f3f3f3; padding-top: 4px; margin: 10px; text-align:center; float: right;"><img src="http://cdn2.brettterpstra.com/wp-content/uploads/2011/11/How-I-roll.jpg?9d7bd4" alt="Dock screenshot" title="How I roll" width="330" height="119" class="size-full wp-image-3124" /><p style=' padding: 0 4px 5px; margin: 0;'  class="wp-caption-text">These are a few of my favorite things</p></div>

<p>I know it sounds like I’m drunk now, screaming “man, I love you guys” at mere acquaintances, but I assure you I’m simply impressed enough to have to blabber on for a while.</p>

<p>I also know I’ve already <a href="http://brettterpstra.com/app-review-byword/">reviewed Byword</a>, but I’ll say this: they’ve already turned what started out as an (in my opinion) over-simplified “distraction-free” editor into a beautiful and powerful writing tool, while still maintaining its minimalist interface. It’s like the developers are hacking into my emails (and my brain) and just doing everything I’ve always wanted.</p>

<p>Keep up the awesome work, MetaClassy, you’re quickly setting the bar for Markdown editors.</p>

<div class="footnotes">
<hr />
<ol>

<li id="fn:caret">
<p>I’m referring to the cursor in the text editor by its “proper” name (caret) to avoid confusion with the mouse cursor. <a href="#fnref:caret" rev="footnote">↩</a></p>
</li>

<li id="fn:nvalt">
<p>Elastic Threads has worked his butt off on a bunch of equally well-thought-out and ingenious features for nvALT. When I get my act together and finish up my part, you’ll all see what I mean. Paste a url onto a selection and turn it into a Markdown link with intelligent detection of whether it should be a reference link or an inline link? Seriously. <a href="#fnref:nvalt" rev="footnote">↩</a></p>
</li>

</ol>
</div>
<p>Related posts:<ol>
<li><a href='http://brettterpstra.com/quick-tip-repeat-cocoa-text-actions-emacsvim-style/' rel='bookmark' title='Quick Tip: repeat Cocoa text actions, Emacs/Vim style'>Quick Tip: repeat Cocoa text actions, Emacs/Vim style</a></li>
<li><a href='http://brettterpstra.com/mac-app-giveaway-byword/' rel='bookmark' title='Mac App Giveaway: Byword'>Mac App Giveaway: Byword</a></li>
<li><a href='http://brettterpstra.com/a-couple-of-textmate-macros-for-markdown-lists/' rel='bookmark' title='A couple of TextMate Macros for Markdown lists'>A couple of TextMate Macros for Markdown lists</a></li>
</ol></p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/byword-for-keyboard-nerds/">Byword for keyboard nerds</a></p>]]></content:encoded>
			<wfw:commentRss>http://brettterpstra.com/byword-for-keyboard-nerds/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>KeyBinding madness</title>
		<link>http://brettterpstra.com/keybinding-madness/</link>
		<comments>http://brettterpstra.com/keybinding-madness/#comments</comments>
		<pubDate>Sat, 13 Aug 2011 16:23:36 +0000</pubDate>
		<dc:creator>Brett</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[keybindings]]></category>
		<category><![CDATA[keyboard]]></category>
		<category><![CDATA[os x]]></category>

		<guid isPermaLink="false">http://brettterpstra.com/?p=2506</guid>
		<description><![CDATA[<p>There’s a somewhat mysterious individual who is consistently leaving brilliant little pieces of code and information in my comments. Dr. Drang has been visited by this apparition as well. We’re both duly impressed with what he (or she?) does. So, I’m digging through the code Lri’s posted and I find a DefaultKeyBinding.dict file. It’s the best one I’ve ever seen,&#8230;</p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/keybinding-madness/">KeyBinding madness</a></p>]]></description>
			<content:encoded><![CDATA[<p><img style=' float: right; padding: 4px; margin: 0 0 2px 7px;'  class="alignright size-full wp-image-2508" title="mackeys" src="http://cdn2.brettterpstra.com/wp-content/uploads/2011/08/mackeys.jpg?9d7bd4" alt="" width="350" height="333" />There’s a somewhat mysterious individual who is consistently leaving brilliant little pieces of code and information in my comments. <a href="http://www.leancrew.com/all-this/">Dr. Drang</a> has been visited by this apparition as well. We’re both duly impressed with what he (or she?) does.</p>

<p>So, I’m digging through the code Lri’s posted and I find a DefaultKeyBinding.dict file. It’s the best one I’ve ever seen, and it inspires me to do some “fiddling” of my own. I figured I’d post my result, but with due credit to Lri (hi, Lri!).</p>

<p>The DefaultKeyBinding.dict file tells your computer at a fairly root level how to handle keyboard shortcuts in input fields. It doesn’t work everywhere, but sometimes it’s surprising where it <em>does</em> work. In those cases, you can save yourself a ton of time by committing a few custom keystrokes to memory.</p>

<p>You may be familiar with the basic Emacs keybindings that are default (Ctrl-a beginning of line, Ctrl-e end of line, etc.), but this allows you to go much further. For more information, check out <a href="http://hints.macworld.com/article.php?story=20060317045211408">Macworld hints</a>, an older but very relevant <a href="http://www.hcs.harvard.edu/~jrus/site/cocoa-text.html">article from Harvard</a> and do <a href="http://duckduckgo.com/?q=cocoa+defaultkeybindings.dict">a search for more information</a>.</p>

<p>Basically, all you need to do is put the DefaultKeyBinding.dict file into <code>~/Library/KeyBindings</code> and restart applications you want it to work in. Edit away, and change shortcuts to things you’re comfortable with. Several of mine are sequences which allow groupings, which I like, but you might not. Be aware that these can be a little unpredictable as to when they’ll override a system/application default and when they’ll be overridden (I know there’s a logic to it, I just don’t want to dive into that).</p>

<p>I’ve posted my <a href="https://github.com/ttscoff/KeyBindings">KeyBindings on GitHub</a> and included a cheatsheet in MultiMarkdown as well as a Readme with the tables already rendered. Direct download link below. If you’re looking for something to nerd out on this weekend, this should whet your appetite.</p>

<div class="download_desc"><p class="download-icon"><a href="http://brettterpstra.com/downloads/keybindings" title="Download Killer DefaultKeyBinding.dict (773)"><img src="http://cdn2.brettterpstra.com/wp-content/uploads/downloads/thumbnails/2011/08/Keyboard_Down.png?9d7bd4" alt="download image for Killer DefaultKeyBinding.dict" width="64" /></a><br /><a href="http://brettterpstra.com/downloads/keybindings" title="Download Killer DefaultKeyBinding.dict (773)" class="download-button">Download</a></p><p class="desc"><a href="http://brettterpstra.com/downloads/keybindings" title="Download Killer DefaultKeyBinding.dict (773)">Killer DefaultKeyBinding.dict</a> — A custom DefaultKeyBinding.dict file which adds shortcuts for document navigation, Markdown and much more. Inspired by <a href="http://www.cs.helsinki.fi/u/lranta/keybindings/">Lri</a>. <a href="http://brettterpstra.com/keybinding-madness/">More Info</a></p></div>

<p>Just for reference, here’s the table of shortcuts in the KeyBindings file:</p>

<p><span id="more-2506"></span></p>

<p><em>Grouped items begin with the groups shortcut, followed by the Keys specified. Items separated by commas are sequential, not concurrent.</em></p>

<table>
<caption id="allpurposekeycombos"> All purpose key combos </caption>
<colgroup>
<col style="text-align:center;"/>
<col style="text-align:center;"/>
<col style="text-align:left;"/>
</colgroup>

<thead>
<tr>
    <th style="text-align:center;">Group</th>
    <th style="text-align:center;">Keys</th>
    <th style="text-align:left;">Function</th>
</tr>
</thead>

<tbody>
<tr>
    <td style="text-align:center;"></td>
    <td style="text-align:center;">Opt-z</td>
    <td style="text-align:left;">copy character before cursor</td>
</tr>
<tr>
    <td style="text-align:center;"></td>
    <td style="text-align:center;">Opt-r</td>
    <td style="text-align:left;">repeat character before cursor</td>
</tr>
<tr>
    <td style="text-align:center;"></td>
    <td style="text-align:center;">Opt-t</td>
    <td style="text-align:left;">transpose characters</td>
</tr>
<tr>
    <td style="text-align:center;"></td>
    <td style="text-align:center;">Opt-+</td>
    <td style="text-align:left;">uppercase word</td>
</tr>
<tr>
    <td style="text-align:center;"></td>
    <td style="text-align:center;">Opt–</td>
    <td style="text-align:left;">lowercase word</td>
</tr>
<tr>
    <td style="text-align:center;"></td>
    <td style="text-align:center;">Opt-.</td>
    <td style="text-align:left;">capitalize word</td>
</tr>
<tr>
    <td style="text-align:center;"></td>
    <td style="text-align:center;">Ctrl-w</td>
    <td style="text-align:left;">delete word before cursor</td>
</tr>
<tr>
    <td style="text-align:center;"></td>
    <td style="text-align:center;">Opt-w</td>
    <td style="text-align:left;">select word</td>
</tr>
<tr>
    <td style="text-align:center;"></td>
    <td style="text-align:center;">Opt-f</td>
    <td style="text-align:left;">cut word (fold)</td>
</tr>
<tr>
    <td style="text-align:center;"></td>
    <td style="text-align:center;">Opt-g</td>
    <td style="text-align:left;">copy word (grab)</td>
</tr>
<tr>
    <td style="text-align:center;"></td>
    <td style="text-align:center;">Opt-h</td>
    <td style="text-align:left;">paste word (hit)</td>
</tr>
<tr>
    <td style="text-align:center;"></td>
    <td style="text-align:center;">Opt-l</td>
    <td style="text-align:left;">select entire line/paragraph</td>
</tr>
<tr>
    <td style="text-align:center;"></td>
    <td style="text-align:center;">Opt-s</td>
    <td style="text-align:left;">select from beginning of paragrah to last character</td>
</tr>
<tr>
    <td style="text-align:center;"></td>
    <td style="text-align:center;">Opt-d</td>
    <td style="text-align:left;">delete line/paragraph</td>
</tr>
<tr>
    <td style="text-align:center;"></td>
    <td style="text-align:center;">Opt-y</td>
    <td style="text-align:left;">copy paragraph</td>
</tr>
<tr>
    <td style="text-align:center;"></td>
    <td style="text-align:center;">Opt-x</td>
    <td style="text-align:left;">cut paragraph</td>
</tr>
<tr>
    <td style="text-align:center;"></td>
    <td style="text-align:center;">Opt-p</td>
    <td style="text-align:left;">paste paragraph below</td>
</tr>
<tr>
    <td style="text-align:center;"></td>
    <td style="text-align:center;">Opt-Shift-P</td>
    <td style="text-align:left;">paste paragraph above</td>
</tr>
<tr>
    <td style="text-align:center;"></td>
    <td style="text-align:center;">Ctrl-Shift-A</td>
    <td style="text-align:left;">select to beginning of paragraph and copy</td>
</tr>
<tr>
    <td style="text-align:center;"></td>
    <td style="text-align:center;">Ctrl-Shift-E</td>
    <td style="text-align:left;">select to end of paragraph and copy</td>
</tr>
<tr>
    <td style="text-align:center;"></td>
    <td style="text-align:center;">Opt-q</td>
    <td style="text-align:left;">cut to beginning of paragraph</td>
</tr>
<tr>
    <td style="text-align:center;"></td>
    <td style="text-align:center;">Opt-k</td>
    <td style="text-align:left;">cut to end of paragraph</td>
</tr>
<tr>
    <td style="text-align:center;"></td>
    <td style="text-align:center;">Opt-,</td>
    <td style="text-align:left;">move paragraph up a line, inserting blank space after</td>
</tr>
<tr>
    <td style="text-align:center;"></td>
    <td style="text-align:center;">Opt-␠</td>
    <td style="text-align:left;">move paragraph to end of document</td>
</tr>
<tr>
    <td style="text-align:center;"></td>
    <td style="text-align:center;">Opt-o</td>
    <td style="text-align:left;">blank line after current</td>
</tr>
<tr>
    <td style="text-align:center;"></td>
    <td style="text-align:center;">Opt-Shift-O</td>
    <td style="text-align:left;">blank line before current</td>
</tr>
<tr>
    <td style="text-align:center;"></td>
    <td style="text-align:center;">Cmd-Opt-/</td>
    <td style="text-align:left;">comment with “//”</td>
</tr>
<tr>
    <td style="text-align:center;"></td>
    <td style="text-align:center;">Cmd-Opt-3</td>
    <td style="text-align:left;">comment with “#”</td>
</tr>
</tbody>
</table>

<table>
<caption id="markdown-specificshortcutsx2318w"> Markdown-specific shortcuts (Ctrl-Cmd-W) </caption>
<colgroup>
<col style="text-align:center;"/>
<col style="text-align:center;"/>
<col style="text-align:left;"/>
</colgroup>

<thead>
<tr>
    <th style="text-align:center;">Group</th>
    <th style="text-align:center;">Keys</th>
    <th style="text-align:left;">Function</th>
</tr>
</thead>

<tbody>
<tr>
    <td style="text-align:center;"></td>
    <td style="text-align:center;">Cmd-Opt-b</td>
    <td style="text-align:left;">bold selection</td>
</tr>
<tr>
    <td style="text-align:center;"></td>
    <td style="text-align:center;">Cmd-Opt-i</td>
    <td style="text-align:left;">italicize selection</td>
</tr>
<tr>
    <td style="text-align:center;">Ctrl-Cmd-w</td>
    <td style="text-align:center;">Return</td>
    <td style="text-align:left;">force Return</td>
</tr>
<tr>
    <td style="text-align:center;">Ctrl-Cmd-w</td>
    <td style="text-align:center;">Tab</td>
    <td style="text-align:left;">force Tab</td>
</tr>
<tr>
    <td style="text-align:center;">Ctrl-Cmd-w</td>
    <td style="text-align:center;">1–4</td>
    <td style="text-align:left;"># Headlines</td>
</tr>
<tr>
    <td style="text-align:center;">Ctrl-Cmd-w</td>
    <td style="text-align:center;">l,t</td>
    <td style="text-align:left;">link text <code>"[selected text](|)"</code></td>
</tr>
<tr>
    <td style="text-align:center;">Ctrl-Cmd-w</td>
    <td style="text-align:center;">l,c</td>
    <td style="text-align:left;">clipboard link <code>"[|selected text](clipboard contents)"</code></td>
</tr>
<tr>
    <td style="text-align:center;">Ctrl-Cmd-w</td>
    <td style="text-align:center;">i,t</td>
    <td style="text-align:left;">image, selection as alt <code>"![selected text](|)"</code></td>
</tr>
<tr>
    <td style="text-align:center;">Ctrl-Cmd-w</td>
    <td style="text-align:center;">i,c</td>
    <td style="text-align:left;">clipboard image <code>"![|selected text](clipboard contents)"</code></td>
</tr>
<tr>
    <td style="text-align:center;">Ctrl-Cmd-w</td>
    <td style="text-align:center;">:,t</td>
    <td style="text-align:left;">create a reference from selected text</td>
</tr>
<tr>
    <td style="text-align:center;">Ctrl-Cmd-w</td>
    <td style="text-align:center;">:,c</td>
    <td style="text-align:left;">create a reference from selected text, clipboard as url</td>
</tr>
<tr>
    <td style="text-align:center;">Ctrl-Cmd-w</td>
    <td style="text-align:center;">[</td>
    <td style="text-align:left;">insert reference link</td>
</tr>
<tr>
    <td style="text-align:center;">Ctrl-Cmd-w</td>
    <td style="text-align:center;">+|-|*</td>
    <td style="text-align:left;">lists</td>
</tr>
<tr>
    <td style="text-align:center;"></td>
    <td style="text-align:center;">Opt-Shift-L</td>
    <td style="text-align:left;">new list item after current</td>
</tr>
<tr>
    <td style="text-align:center;">Ctrl-Cmd-w</td>
    <td style="text-align:center;">e</td>
    <td style="text-align:left;">entity</td>
</tr>
<tr>
    <td style="text-align:center;">Ctrl-Cmd-w</td>
    <td style="text-align:center;">/</td>
    <td style="text-align:left;">http://</td>
</tr>
</tbody>
</table>

<table>
<caption id="surroundx2318s"> Surround (Ctrl-Cmd-s) </caption>
<colgroup>
<col style="text-align:center;"/>
<col style="text-align:center;"/>
<col style="text-align:left;"/>
</colgroup>

<thead>
<tr>
    <th style="text-align:center;">Group</th>
    <th style="text-align:center;">Keys</th>
    <th style="text-align:left;">Function</th>
</tr>
</thead>

<tbody>
<tr>
    <td style="text-align:center;">Ctrl-Cmd-s</td>
    <td style="text-align:center;">(</td>
    <td style="text-align:left;">wrap () with spaces</td>
</tr>
<tr>
    <td style="text-align:center;">Ctrl-Cmd-s</td>
    <td style="text-align:center;">)</td>
    <td style="text-align:left;">wrap () no spaces</td>
</tr>
<tr>
    <td style="text-align:center;">Ctrl-Cmd-s</td>
    <td style="text-align:center;">[</td>
    <td style="text-align:left;">wrap [] with spaces</td>
</tr>
<tr>
    <td style="text-align:center;">Ctrl-Cmd-s</td>
    <td style="text-align:center;">]</td>
    <td style="text-align:left;">wrap [] no spaces</td>
</tr>
<tr>
    <td style="text-align:center;">Ctrl-Cmd-s</td>
    <td style="text-align:center;">{</td>
    <td style="text-align:left;">wrap {} with spaces</td>
</tr>
<tr>
    <td style="text-align:center;">Ctrl-Cmd-s</td>
    <td style="text-align:center;">}</td>
    <td style="text-align:left;">wrap {} no spaces</td>
</tr>
<tr>
    <td style="text-align:center;">Ctrl-Cmd-s</td>
    <td style="text-align:center;">&lt;</td>
    <td style="text-align:left;">wrap &lt;&gt; with spaces</td>
</tr>
<tr>
    <td style="text-align:center;">Ctrl-Cmd-s</td>
    <td style="text-align:center;">&gt;</td>
    <td style="text-align:left;">wrap &lt;&gt; no spaces</td>
</tr>
<tr>
    <td style="text-align:center;">Ctrl-Cmd-s</td>
    <td style="text-align:center;">’</td>
    <td style="text-align:left;">wrap single quotes</td>
</tr>
<tr>
    <td style="text-align:center;">Ctrl-Cmd-s</td>
    <td style="text-align:center;">‘</td>
    <td style="text-align:left;">wrap backticks</td>
</tr>
<tr>
    <td style="text-align:center;">Ctrl-Cmd-s</td>
    <td style="text-align:center;">”</td>
    <td style="text-align:left;">wrap double quote</td>
</tr>
</tbody>
</table>

<table>
<caption id="listparagraphmotion"> List/Paragraph motion </caption>
<colgroup>
<col style="text-align:center;"/>
<col style="text-align:center;"/>
<col style="text-align:left;"/>
</colgroup>

<thead>
<tr>
    <th style="text-align:center;">Group</th>
    <th style="text-align:center;">Keys</th>
    <th style="text-align:left;">Function</th>
</tr>
</thead>

<tbody>
<tr>
    <td style="text-align:center;"></td>
    <td style="text-align:center;">Ctrl-Cmd-k</td>
    <td style="text-align:left;">move line up</td>
</tr>
<tr>
    <td style="text-align:center;"></td>
    <td style="text-align:center;">Ctrl-Cmd-j</td>
    <td style="text-align:left;">move line down</td>
</tr>
<tr>
    <td style="text-align:center;"></td>
    <td style="text-align:center;">Ctrl-Cmd-l</td>
    <td style="text-align:left;">indent line</td>
</tr>
<tr>
    <td style="text-align:center;"></td>
    <td style="text-align:center;">Ctrl-Cmd-h</td>
    <td style="text-align:left;">outdent line (all the way)</td>
</tr>
<tr>
    <td style="text-align:center;"></td>
    <td style="text-align:center;">Ctrl-Opt-k</td>
    <td style="text-align:left;">copy line and paste above</td>
</tr>
<tr>
    <td style="text-align:center;"></td>
    <td style="text-align:center;">Ctrl-Opt-j</td>
    <td style="text-align:left;">copy line and paste below</td>
</tr>
<tr>
    <td style="text-align:center;"></td>
    <td style="text-align:center;">Cmd-Opt-Up</td>
    <td style="text-align:left;">modify selection up</td>
</tr>
<tr>
    <td style="text-align:center;"></td>
    <td style="text-align:center;">Cmd-Opt-Down</td>
    <td style="text-align:left;">modify selection down</td>
</tr>
<tr>
    <td style="text-align:center;"></td>
    <td style="text-align:center;">Cmd-Del</td>
    <td style="text-align:left;">Forward delete to end of paragraph</td>
</tr>
</tbody>
</table>

<table>
<caption id="documentnavigation"> Document navigation </caption>
<colgroup>
<col style="text-align:center;"/>
<col style="text-align:center;"/>
<col style="text-align:left;"/>
</colgroup>

<thead>
<tr>
    <th style="text-align:center;">Group</th>
    <th style="text-align:center;">Keys</th>
    <th style="text-align:left;">Function</th>
</tr>
</thead>

<tbody>
<tr>
    <td style="text-align:center;"></td>
    <td style="text-align:center;">PgUp</td>
    <td style="text-align:left;">Page Up</td>
</tr>
<tr>
    <td style="text-align:center;"></td>
    <td style="text-align:center;">PgDown</td>
    <td style="text-align:left;">Page Down</td>
</tr>
<tr>
    <td style="text-align:center;"></td>
    <td style="text-align:center;">Opt-PgUp</td>
    <td style="text-align:left;">Scroll up</td>
</tr>
<tr>
    <td style="text-align:center;"></td>
    <td style="text-align:center;">Opt-PgDown</td>
    <td style="text-align:left;">Scroll Down</td>
</tr>
<tr>
    <td style="text-align:center;"></td>
    <td style="text-align:center;">Opt-1</td>
    <td style="text-align:left;">bookmark</td>
</tr>
<tr>
    <td style="text-align:center;"></td>
    <td style="text-align:center;">Opt-2</td>
    <td style="text-align:left;">jump to bookmark</td>
</tr>
</tbody>
</table>
<p>Related posts:<ol>
<li><a href='http://brettterpstra.com/keybindings-new-improved-surround-commands/' rel='bookmark' title='KeyBindings: new, improved “surround” commands'>KeyBindings: new, improved “surround” commands</a></li>
<li><a href='http://brettterpstra.com/the-keys-that-bind-keybinding-madness-part-2/' rel='bookmark' title='The keys that bind: KeyBinding Madness part 2'>The keys that bind: KeyBinding Madness part 2</a></li>
<li><a href='http://brettterpstra.com/option-arrow-navigation-in-iterm2/' rel='bookmark' title='Option-arrow navigation in iTerm2'>Option-arrow navigation in iTerm2</a></li>
</ol></p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/keybinding-madness/">KeyBinding madness</a></p>]]></content:encoded>
			<wfw:commentRss>http://brettterpstra.com/keybinding-madness/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>Option-arrow navigation in iTerm2</title>
		<link>http://brettterpstra.com/option-arrow-navigation-in-iterm2/</link>
		<comments>http://brettterpstra.com/option-arrow-navigation-in-iterm2/#comments</comments>
		<pubDate>Fri, 12 Aug 2011 15:19:49 +0000</pubDate>
		<dc:creator>Brett</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[iterm2]]></category>
		<category><![CDATA[keyboard]]></category>
		<category><![CDATA[terminal]]></category>

		<guid isPermaLink="false">http://brettterpstra.com/?p=2489</guid>
		<description><![CDATA[<p>Update: See the comments for more (and possibly better) solutions from readers! I’ve been trying to get Option-arrow keys to move by word in iTerm2. I figured out a solution, but it’s weird. If anyone has an explanation or a better way to do this, let me know. First, I had to edit my ~/.inputrc file and add these lines:&#8230;</p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/option-arrow-navigation-in-iterm2/">Option-arrow navigation in iTerm2</a></p>]]></description>
			<content:encoded><![CDATA[<p><strong>Update:</strong> See the comments for more (and possibly better) solutions from readers!</p>

<p>I’ve been trying to get Option-arrow keys to move by word in iTerm2. I figured out a solution, but it’s weird. If anyone has an explanation or a better way to do this, let me know.</p>

<p>First, I had to edit my <code>~/.inputrc</code> file and add these lines:</p>

<pre><code>"\e[1;5C": forward-word
"\e[1;5D": backward-word
</code></pre>

<p><a href="http://cdn2.brettterpstra.com/wp-content/uploads/2011/08/iTerm2SettingsPanel-2.jpg?9d7bd4"><img style=' float: right; padding: 4px; margin: 0 0 2px 7px;'  src="http://cdn2.brettterpstra.com/wp-content/uploads/2011/08/iTerm2SettingsPanel-2-300x224.jpg?9d7bd4" alt="iTerm2 Preference Panel screenshot" title="iTerm2 Settings Panel" width="300" height="224" class="alignright size-medium wp-image-2492 shadow" /></a>Then I had to set up in iTerm2 preferences–under Profiles-&gt;Keys–the options for both key combinations:</p>

<ul>
<li>Add a hotkey with the plus symbol at the bottom of the hotkey list</li>
<li>Set the keyboard shortcut by pressing Option-left or Option-right</li>
<li>Set the action to “Send Escape Sequence”</li>
<li>Set the Esc+ field to:

<ul>
<li>[1;5C (Option-Right)</li>
<li>[1;5D (Option-Left)   </li>
</ul></li>
</ul>

<p>With these in place both work swimmingly. I don’t know why I had to do both parts, though…</p>
<p>Related posts:<ol>
<li><a href='http://brettterpstra.com/keybinding-madness/' rel='bookmark' title='KeyBinding madness'>KeyBinding madness</a></li>
<li><a href='http://brettterpstra.com/filesystem-navigation-with-textexpander/' rel='bookmark' title='Filesystem navigation with TextExpander'>Filesystem navigation with TextExpander</a></li>
<li><a href='http://brettterpstra.com/quick-tip-this-command-line-trick-is-tops/' rel='bookmark' title='Quick Tip: This command line trick is tops'>Quick Tip: This command line trick is tops</a></li>
</ol></p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/option-arrow-navigation-in-iterm2/">Option-arrow navigation in iTerm2</a></p>]]></content:encoded>
			<wfw:commentRss>http://brettterpstra.com/option-arrow-navigation-in-iterm2/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Clear sticky Growl notifications with a keyboard shortcut</title>
		<link>http://brettterpstra.com/clear-sticky-growl-notifications-with-a-keyboard-shortcut/</link>
		<comments>http://brettterpstra.com/clear-sticky-growl-notifications-with-a-keyboard-shortcut/#comments</comments>
		<pubDate>Sat, 25 Sep 2010 21:05:35 +0000</pubDate>
		<dc:creator>Brett</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[applescript]]></category>
		<category><![CDATA[growl]]></category>
		<category><![CDATA[keyboard]]></category>
		<category><![CDATA[os x]]></category>
		<category><![CDATA[scripting]]></category>

		<guid isPermaLink="false">http://brettterpstra.com/?p=1022</guid>
		<description><![CDATA[<p>I ran into a question yesterday that didn’t seem to have an obvious answer: how can I clear a stack of sticky Growl notifications using only the keyboard. It’s not been any secret that I’m a fan of keyboard shortcuts, as indicated by the extensive keyboard support I’ve added to Instapaper Beyond. So I decided to make an interim solution&#8230;</p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/clear-sticky-growl-notifications-with-a-keyboard-shortcut/">Clear sticky Growl notifications with a keyboard shortcut</a></p>]]></description>
			<content:encoded><![CDATA[<p><img style=' float: right; padding: 4px; margin: 0 0 2px 7px;'  src="http://cdn2.brettterpstra.com/wp-content/uploads/2010/09/GrowlHelperApp.jpg?9d7bd4" alt="GrowlHelperApp.jpg" border="0" width="312" height="88" class="alignright" />I ran into a question yesterday that didn’t seem to have an obvious answer: how can I clear a stack of sticky <a href="http://growl.info/">Growl</a> notifications using only the keyboard. It’s not been any secret that I’m a fan of keyboard shortcuts, as indicated by the extensive keyboard support I’ve added to <a href="http://brettterpstra.com/instapaperbeyond/">Instapaper Beyond</a>. So I decided to make an interim solution until a specific feature for this is added, either to the Growl preferences or via AppleScript support.</p>

<p>For the record, I’m fully aware of the Option-Click shortcut to make all current notifications disappear, but thanks to all of the Twitter responses to that effect nonetheless. I really wanted a pure keyboard solution to handle this (I’m <a href="http://code.google.com/p/growl/issues/detail?id=11">not alone</a>). Usually, at least with apps that adhere to the Growl suggestion regarding stickiness, you only get sticky notifications when something goes wrong, and then you usually get more than one. I just wanted to be able to “poof” them away quickly and tend to whatever was causing them. I’m weird, I know.</p>

<p>After a lot of toying around, I decided to just go with a brute force method: quit the helper application and start it back up. It does the trick, and if you use AppleScript to handle the process, you can keep the bridge alive and experience no interruption in your Growl service. If you call the <a href="http://brettterpstra.com/tag/applescript/">AppleScript</a> with <a href="http://www.red-sweater.com/fastscripts/">FastScripts</a>, a launcher like <a href="http://www.shadowlab.org/Software/spark.php">Spark</a> or even <a href="http://code.google.com/p/blacktree-alchemy/">QuickSilver</a> or <a href="http://www.obdev.at/products/launchbar/index.html">LaunchBar</a>, you can cause all sticky notifications to disappear with a keystroke of your choice.</p>

<p>Here’s the script:</p>

<div markdown=0>
<pre><code>
tell application "GrowlHelperApp" to quit
delay 1
tell application "GrowlHelperApp" to activate
</code></pre>
</div>

<p>I found the 1 second delay necessary to let the process close out before trying to launch it again. If you run into issues with Growl not responding after running this script, you might try increasing that delay by a second or two. I also played around with using kill (grep/awk for the PID, kill the process, etc.), but the whole system stays much more stable this way.</p>

<p>There, my contribution to the keyboard-obsessed minority of OS X users.</p>
<p>Related posts:<ol>
<li><a href='http://brettterpstra.com/quick-tip-quickly-clear-stuck-growl-notifications/' rel='bookmark' title='Quick Tip: Quickly clear stuck Growl notifications'>Quick Tip: Quickly clear stuck Growl notifications</a></li>
<li><a href='http://brettterpstra.com/quick-tip-applescript-application-toggle/' rel='bookmark' title='Quick tip: AppleScript application toggle'>Quick tip: AppleScript application toggle</a></li>
<li><a href='http://brettterpstra.com/answer-skype-with-a-hotkey/' rel='bookmark' title='Answer Skype with a hotkey'>Answer Skype with a hotkey</a></li>
</ol></p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/clear-sticky-growl-notifications-with-a-keyboard-shortcut/">Clear sticky Growl notifications with a keyboard shortcut</a></p>]]></content:encoded>
			<wfw:commentRss>http://brettterpstra.com/clear-sticky-growl-notifications-with-a-keyboard-shortcut/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>A quick TextMate KeyBindings tip</title>
		<link>http://brettterpstra.com/textmate-keybinding-tip/</link>
		<comments>http://brettterpstra.com/textmate-keybinding-tip/#comments</comments>
		<pubDate>Fri, 13 Aug 2010 19:19:52 +0000</pubDate>
		<dc:creator>Brett</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[keybindings]]></category>
		<category><![CDATA[keyboard]]></category>
		<category><![CDATA[terminal]]></category>
		<category><![CDATA[textmate]]></category>

		<guid isPermaLink="false">http://brettterpstra.com/?p=891</guid>
		<description><![CDATA[<p>I love the keyboard, and I love keyboard shortcuts. It’s one of the reasons TextMate and I get along so well. There’s one thing that bothers me any time I’m editing text (in any application), though: having to move my right hand all the way over to the arrow keys just to move forward a couple of characters, say, after&#8230;</p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/textmate-keybinding-tip/">A quick TextMate KeyBindings tip</a></p>]]></description>
			<content:encoded><![CDATA[<p><img style=' float: right; padding: 4px; margin: 0 0 2px 7px;'  src="http://cdn2.brettterpstra.com/wp-content/uploads/2010/08/keybindingstypewriter1.jpg?9d7bd4" alt="Typewriter Image" border="0" width="318" height="301" class="alignright noshadow" />I love the keyboard, and I love keyboard shortcuts. It’s one of the reasons TextMate and I get along so well. There’s one thing that bothers me any time I’m editing text (in any application), though: having to move my right hand <em>all</em> the way over to the arrow keys just to move forward a couple of characters, say, after an auto-paired set of parenthesis that I want to get out of.</p>

<p>I know, it’s stupid for two reasons: first, it’s just not that big a deal, and second, I could just use the Emacs keybindings (^F,^B,^P,^N, etc.). Well, to that I say “phooey” on both counts. It <em>is</em> a big deal; I’ve probably lost hours of my life to that motion. As to the latter, I didn’t grow up on Emacs, and those shortcuts have just never nestled into my muscle memory. In related news, I already have some of those keys bound elsewhere.</p>

<p>I used to use <a href="http://pqrs.org/macosx/keyremap4macbook/">KeyRemap4Macbook</a> to map control-j,i,l and m to the cursor keys, but haven’t installed it since my last clean wipe (just in case it was part of the reason I had to do the clean wipe to begin with). I missed that convenience, though, so after 15 minutes of Googling, here’s the answer…</p>

<p><span id="more-891"></span></p>

<p>Allan Odgaard, creator of TextMate, offers the beginning of the solution <a href="http://blog.macromates.com/2005/key-bindings-for-switchers/">on the TextMate blog</a>. I found a little <a href="http://xahlee.org/emacs/osx_keybinding.html">more detailed information</a> around the net, too. Basically, you can add or edit a file called <code>DefaultKeyBinding.dict</code> in <code>~/Library/KeyBindings/</code> to add the keystrokes to all Cocoa applications. Mine looks like this now:</p>

<div markdown=0>
<pre><code>
{
  "^j" = "moveBackward:";
  "^l" = "moveForward:";
  "^m" = "moveDown:";
  "^i" = "moveUp:";
  "^E" = "\"editInTextMate:\"";
}
</code></pre>
</div>

<p>The first part of each pair is the keystroke, and the second part is the action. To find a list of the available actions, I just looked at <code>/System/Library/Frameworks/AppKit.framework/Resources/StandardKeyBinding.dict</code>, which has all of the default OS X keybindings in it. You’ll need Property List Editor to view the file in its default state. To view the file in a text editor, you have to convert it to an XML (old school and plain text) plist. If you’re curious, copy the file to your Desktop and, in Terminal, run <code>plutil -convert xml1 ~/Desktop/StandardKeyBinding.dict</code>.</p>

<p>After editing <code>DefaultKeyBinding.dict</code> and restarting your Cocoa apps, your new keyboard shortcuts will be available. That’s when I found the next problem. TextMate has ^J mapped to “Reformat and Justify” under the Text menu. I never, ever use that command, so that was just annoying. I first tried to just override it in System Preferences-&gt;Keyboard-&gt;Application Shortcuts, but that didn’t do anything. Next I found a <a href="http://www.macosxhints.com/article.php?story=20040618093419348">post on macosxhints</a> that offered a Terminal (<code>defaults</code>) command for changing default Application shortcuts. For example:</p>

<div markdown=0>
<pre><code>
defaults write com.macromates.textmate NSUserKeyEquivalents -dict-add "Reformat and Justify" "nil"
</code></pre>
</div>

<p>Guess what? That didn’t do it. TextMate was still pwning the ^J shortcut. Next stop, the Resources folder of the TextMate application. There I found <code>KeyBindings.dict</code>, where it was easy to locate the offending shortcut. I commented out the line (//) and restarted TextMate. Ta. Dum. My new keyboard shortcuts now function perfectly.</p>

<p>By the way, the reason I didn’t use “k” for down is I actually do regularly use the <code>kill</code> keybinding to delete to the end of the line (as well as ^a to move to beginning and ^e to the end). Also, you might skip mapping “m” to down, as “n” right next to it is already mapped to moveDown:, as mentioned while complaining about Emacs keybindings. I have them both mapped now, so I can have lazy fingers if I want to. Further, note that these keybindings will not work when selecting text; once you press the shift key, you’re in a whole new world. You’d have map those as well if you wanted that functionality.</p>

<p>I’m happy now, and so are my fingers. Have any other brilliant keybinding stories? I’d love to hear them.</p>
<p>Related posts:<ol>
<li><a href='http://brettterpstra.com/keybindings-new-improved-surround-commands/' rel='bookmark' title='KeyBindings: new, improved “surround” commands'>KeyBindings: new, improved “surround” commands</a></li>
<li><a href='http://brettterpstra.com/keybinding-madness/' rel='bookmark' title='KeyBinding madness'>KeyBinding madness</a></li>
<li><a href='http://brettterpstra.com/the-keys-that-bind-keybinding-madness-part-2/' rel='bookmark' title='The keys that bind: KeyBinding Madness part 2'>The keys that bind: KeyBinding Madness part 2</a></li>
</ol></p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/textmate-keybinding-tip/">A quick TextMate KeyBindings tip</a></p>]]></content:encoded>
			<wfw:commentRss>http://brettterpstra.com/textmate-keybinding-tip/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Instapaper Beyond for Fluid.app</title>
		<link>http://brettterpstra.com/instapaper-beyond-fluid/</link>
		<comments>http://brettterpstra.com/instapaper-beyond-fluid/#comments</comments>
		<pubDate>Sun, 28 Mar 2010 09:00:26 +0000</pubDate>
		<dc:creator>Brett</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[fluid]]></category>
		<category><![CDATA[instapaper]]></category>
		<category><![CDATA[instapaper beyond]]></category>
		<category><![CDATA[keyboard]]></category>
		<category><![CDATA[navigation]]></category>
		<category><![CDATA[userscript]]></category>

		<guid isPermaLink="false">http://brettterpstra.com/?p=344</guid>
		<description><![CDATA[<p>Introducing Instapaper Beyond, an Instapaper userscript for Fluid that provides full keyboard navigation and some special features for browsing your Instapaper articles. If you’re not familiar, Fluid is a Mac (only) application which creates a Single Site Browser (SSB) for a site, using the same Webkit engine as Safari. It essentially allows you to turn web applications and sites into&#8230;</p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/instapaper-beyond-fluid/">Instapaper Beyond for Fluid.app</a></p>]]></description>
			<content:encoded><![CDATA[<p>Introducing Instapaper Beyond, an <a href="http://www.instapaper.com">Instapaper</a> userscript for <a href="http://fluidapp.com/">Fluid</a> that provides full keyboard navigation and some special features for browsing your Instapaper articles. If you’re not familiar, Fluid is a Mac (only) application which creates a Single Site Browser (SSB) for a site, using the same Webkit engine as Safari. It essentially allows you to turn web applications and sites into Mac apps. It’s pure Cocoa, so all of your Services and fun text tricks (like Control-T transposition) work on it. Oh, and it includes <a href="http://userstyles.org/">userstyle</a> and <a href="http://userscripts.org/">userscript</a> engines, similar to <a href="https://addons.mozilla.org/en-US/firefox/addon/748">Greasemonkey</a>, which allows nerds like me to do some crazy things. Fluid (WebKit) is the only browser I’ve developed this for, so I doubt Greasemonkey (Firefox) users will have much luck with it.</p>

<div id="attachment_347" class="wp-caption alignright" style="width: 310px;  border: 1px solid #dddddd; background-color: #f3f3f3; padding-top: 4px; margin: 10px; text-align:center; float: right;"><a href="http://cdn2.brettterpstra.com/wp-content/uploads/2010/03/highlighted.jpg?9d7bd4" class="alignright"><img src="http://cdn2.brettterpstra.com/wp-content/uploads/2010/03/highlighted-300x191.jpg?9d7bd4" alt="Screenshot of a highlighted entry" title="Highlighted entry" width="300" height="191" class="size-medium wp-image-347" /></a><p style=' padding: 0 4px 5px; margin: 0;'  class="wp-caption-text">Keyboard navigation highlight</p></div>

<p>Know what you’re doing and want to skip straight to the script? <a href="http://brettterpstra.com/userscripts/instapaperbeyond.user.js?9d7bd4">OK</a>.</p>

<p><span id="more-344"></span>
The script started as an expansion of a cool userscript called <a href="http://userscripts.org/scripts/show/59917">Instapaper Article Tools</a>, which provides a floating menu with some options while in the text view of an article. For the most part, that script isn’t even visible in the final version, unless you manually click into an article. You don’t need to do that, though, because the whole point of the script is to provide keyboard navigation for Instapaper. Articles are loaded via Ajax and you can go from article to article in full-screen text view, starring/unstarring, moving and archiving on the fly. A full list of commands available at any time can be seen by pressing “h”, but here’s a quick overview:</p>

<div id="attachment_373" class="wp-caption alignright" style="width: 310px;  border: 1px solid #dddddd; background-color: #f3f3f3; padding-top: 4px; margin: 10px; text-align:center; float: right;"><img src="http://cdn2.brettterpstra.com/wp-content/uploads/2010/03/InstapaperHelpHud.jpg?9d7bd4" alt="Image of the Instapaper Beyond Help HUD" title="InstapaperHelpHud" width="300" height="301" class="size-full wp-image-373" /><p style=' padding: 0 4px 5px; margin: 0;'  class="wp-caption-text">Help HUD (h)</p></div>

<ul>
<li>“h” will bring up a help screen with the available shortcuts on it</li>
<li>“g” opens a list of folders you can jump to</li>
<li>navigation is fairly intuitive if you use Google Reader or other Google apps, in that j is forward, k is backwards, o is open, u returns to unread articles. </li>
<li>Escape and Enter function as expected (at least to me), closing open dialogs, returning to posts, etc.</li>
<li>In list view, lowercase letters jump to sections (a:Archive, s:Starred, u:unread) and capital letters perform functions (A:Archive, S:Toggle Star).</li>
<li>The delete key deletes the current article in list and text views</li>
<li>see the help (h) for more!</li>
</ul>

<p>Additionally, Instapaper Beyond adds target=_blank to external links (original articles) so that you can open them in tabs or new windows (depending on your tabbed browsing settings). “U” will check for updates to the script and offer you a link to any updated version for easy installation. There’s wraparound navigation of lists, so using any “next” command at the end of a list will take you to the top, and vice versa. I also built myself an easy-to-expand, contextual help system so adding new commands is a snap, and having them show up in the appropriate help menus is automatic. You don’t care so much about that, but hey, it’s cool.</p>

<p>No guarantee is offered that this script will function well with your userstyle of choice, although several have been tested with good results.</p>

<h3>Installation</h3>

<ol>
<li>First, create your Fluid SSB and set http://www.instapaper.com/u as your home page. <a href="http://fluidapp.com/">Download Fluid here</a>, if needed, then run it to create the SSB. <a href="http://cdn2.brettterpstra.com/wp-content/uploads/2010/03/instapapericon1.png?9d7bd4">Here’s a handy icon</a> you can use, too!</li>
<li>Have new windows open with your Home Page under General Settings in Preferences</li>
<li>Under Advanced Settings in Preferences, set your SSB to browse to any url <a href="http://cdn2.brettterpstra.com/wp-content/uploads/2010/03/Advanced-Preferences.jpg?9d7bd4" rel="lightbox">(image)</a></li>
<li>Enable Tabbed Browsing under the Tabs Preferences <a href="http://cdn2.brettterpstra.com/wp-content/uploads/2010/03/Tabs-Preferences.jpg?9d7bd4" rel="lightbox">(image)</a></li>
<li>Install the Instapaper Beyond Userscript: Point your Fluid <acronym title="Single Site Browser">SSB</acronym> at <a href="http://brettterpstra.com/userscripts/instapaperbeyond.user.js?9d7bd4">http://brettterpstra.com/userscripts/instapaperbeyond.user.js</a>. Fluid should automatically recognize it as a userscript and offer to install it for you. If you have any trouble, you can open the link above, copy the entire script and use “New Userscript” under the SSB’s Script menu (looks like a scroll). Name it “Instapaper Beyond” and paste the copied script into the window.</li>
<li>For best results, turn off Auto Archiving in Instapaper by unchecking the box at the bottom of a post list page
<a href="http://cdn2.brettterpstra.com/wp-content/uploads/2010/03/instapaperbeyondarchivesetting.jpg?9d7bd4" rel="lightbox">(image)</a></li>
</ol>

<p>The script is under development, but is stable at this point. Please let me know how it works for you and what you’d like to see! I’m thinking that I’ll eventually use <a href="http://fluidium.org/">Fluidium</a> to make this into a full-blown app with auto-updates, so keep your eyes peeled for that. Remember, “h” for help, “U” to check for new versions! If you need a script to quickly populate your Instapaper account, be sure to check out the <a href="http://brettterpstra.com/2010/03/08/save-safari-tabs-to-instapaper/">“Safari to Instapaper”</a> script I posted earlier.</p>
<p>Related posts:<ol>
<li><a href='http://brettterpstra.com/minor-update-to-instapaper-beyond-1-4/' rel='bookmark' title='Minor update to Instapaper Beyond (1.4)'>Minor update to Instapaper Beyond (1.4)</a></li>
<li><a href='http://brettterpstra.com/a-big-upgrade-for-instapaper-beyond/' rel='bookmark' title='A big upgrade for Instapaper Beyond'>A big upgrade for Instapaper Beyond</a></li>
<li><a href='http://brettterpstra.com/instapaper-beyond-for-safari/' rel='bookmark' title='Instapaper Beyond for Safari'>Instapaper Beyond for Safari</a></li>
</ol></p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/instapaper-beyond-fluid/">Instapaper Beyond for Fluid.app</a></p>]]></content:encoded>
			<wfw:commentRss>http://brettterpstra.com/instapaper-beyond-fluid/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic (Feed is rejected)
Page Caching using disk: enhanced
Database Caching 17/97 queries in 0.334 seconds using xcache
Object Caching 2393/2497 objects using xcache
Content Delivery Network via cdn2.brettterpstra.com

Served from: brettterpstra.com @ 2012-02-09 17:37:26 -->
