<?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>voyce &#187; parentheses</title>
	<atom:link href="http://www.voyce.com/index.php/tag/parentheses/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.voyce.com</link>
	<description>Programming and debugging tidbits</description>
	<lastBuildDate>Sun, 15 Jan 2012 13:10:46 +0000</lastBuildDate>
	
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Visual Studio Toggle Brackets Macro</title>
		<link>http://www.voyce.com/index.php/2009/02/09/visual-studio-toggle-brackets-macro/</link>
		<comments>http://www.voyce.com/index.php/2009/02/09/visual-studio-toggle-brackets-macro/#comments</comments>
		<pubDate>Mon, 09 Feb 2009 12:35:28 +0000</pubDate>
		<dc:creator>ian</dc:creator>
				<category><![CDATA[F#]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[brackets]]></category>
		<category><![CDATA[macro]]></category>
		<category><![CDATA[parentheses]]></category>

		<guid isPermaLink="false">http://www.voyce.com/?p=85</guid>
		<description><![CDATA[After using a F# heavily for a while, I often found myself wanting to add brackets (or rather, parentheses) around some text. This is normally when adding a type specification to an argument in order to be able to use dot notation, e.g. going from:

let typeName t = t.Name

which causes &#8220;error FS0072: Lookup on object [...]]]></description>
			<content:encoded><![CDATA[<p>After using a F# heavily for a while, I often found myself wanting to add brackets (or rather, parentheses) around some text. This is normally when adding a type specification to an argument in order to be able to use dot notation, e.g. going from:</p>
<div style="font-family: Lucida Sans Typewriter; font-size: 10pt; color: black; background: white;">
<p style="margin: 0px;"><span style="color: blue;">let</span> typeName t = t.Name</p>
</div>
<p>which causes &#8220;error FS0072: Lookup on object of indeterminate type based on information prior to this program point&#8221;, to the correct:</p>
<div style="font-family: Lucida Sans Typewriter; font-size: 10pt; color: black; background: white;">
<p style="margin: 0px;"><span style="color: blue;">let</span> typeName <strong>(t:Type)</strong> = t.Name</p>
</div>
<p>(These are obviously simplistic examples!)</p>
<p>So I broke out the Visual Studio macro editor for the first time in a while, and put together something to toggle brackets around the currently selected text. It&#8217;s naive, but, combined with Shift+Alt+Left Arrow to select the previous word, it&#8217;s effective:</p>
<div style="font-family: Courier New; font-size: 10pt; color: black; background: white;">
<p style="margin: 0px;"><span style="color: blue;">Public</span> <span style="color: blue;">Sub</span> AddBrackets()</p>
<p style="margin: 0px;"><span style="color: blue;"> Dim</span> s <span style="color: blue;">As</span> <span style="color: blue;">Object</span> = DTE.ActiveWindow.Selection()</p>
<p style="margin: 0px;"><span style="color: blue;"> If</span> s.Text.StartsWith(<span style="color: #a31515;">&#8220;(&#8221;</span>) <span style="color: blue;">And</span> s.Text.EndsWith(<span style="color: #a31515;">&#8220;)&#8221;</span>) <span style="color: blue;">Then</span></p>
<p style="margin: 0px;">s.Text = s.Text.Substring(1, s.Text.Length &#8211; 2)</p>
<p style="margin: 0px;"><span style="color: blue;"> Else</span></p>
<p style="margin: 0px;">s.Text = <span style="color: #a31515;">&#8220;(&#8221;</span> + s.Text + <span style="color: #a31515;">&#8220;)&#8221;</span></p>
<p style="margin: 0px;"><span style="color: blue;"> End</span> <span style="color: blue;">If</span></p>
<p style="margin: 0px;"><span style="color: blue;">End</span> <span style="color: blue;">Sub</span></p>
</div>
<p>Copy this text into a module within your macro project, and assign a suitable keystroke using Tools|Customize|Keyboard.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.voyce.com/index.php/2009/02/09/visual-studio-toggle-brackets-macro/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

