<?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>Stefano Ricciardi &#187; refactoring</title>
	<atom:link href="http://stefanoricciardi.com/tag/refactoring/feed/" rel="self" type="application/rss+xml" />
	<link>http://stefanoricciardi.com</link>
	<description>On Software Development and Thereabouts</description>
	<lastBuildDate>Tue, 15 Nov 2011 07:57:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>More Visual Studio 2008 Shortcuts: Trasposing Characters, Words and Lines</title>
		<link>http://stefanoricciardi.com/2009/08/13/more-visual-studio-2008-shortcuts-trasposing-characters-words-and-lines/</link>
		<comments>http://stefanoricciardi.com/2009/08/13/more-visual-studio-2008-shortcuts-trasposing-characters-words-and-lines/#comments</comments>
		<pubDate>Thu, 13 Aug 2009 16:30:25 +0000</pubDate>
		<dc:creator>stefanoricciardi</dc:creator>
				<category><![CDATA[Tools]]></category>
		<category><![CDATA[refactoring]]></category>
		<category><![CDATA[Visual Studio 2008]]></category>

		<guid isPermaLink="false">http://stefanoricciardi.net/?p=277</guid>
		<description><![CDATA[I love shortcuts. I really do. So with some excitement I have found a few in the Visual Studio Editor that may come handy once in a while. These are the shortcuts to transpose characters, words and lines: CTRL + T Transpose characters CTRL + SHIFT + T Transpose words ALT + SHIFT + T [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fstefanoricciardi.com%2F2009%2F08%2F13%2Fmore-visual-studio-2008-shortcuts-trasposing-characters-words-and-lines%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fstefanoricciardi.com%2F2009%2F08%2F13%2Fmore-visual-studio-2008-shortcuts-trasposing-characters-words-and-lines%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>I love <a href="http://stefanoricciardi.com/2009/06/10/most-useful-visual-studio-2008-keyboard-shortcuts/">shortcuts</a>. I really do. So with some excitement I have found a few in the Visual Studio Editor that may come handy once in a while. These are the shortcuts to transpose characters, words and lines:</p>
<table border="0" cellspacing="0" cellpadding="2" width="580">
<tbody>
<tr>
<td width="150" valign="top">CTRL + T</td>
<td width="430" valign="top"><strong>Transpose characters</strong></td>
</tr>
<tr>
<td width="150" valign="top">CTRL + SHIFT + T</td>
<td width="430" valign="top"><strong>Transpose words</strong></td>
</tr>
<tr>
<td width="150" valign="top">ALT + SHIFT + T</td>
<td width="430" valign="top"><strong>Transpose lines</strong></td>
</tr>
</tbody>
</table>
<h3>Transposing Characters (CTRL+T)</h3>
<p>This is mostly useful if you mispelled a word. Since most code typing is done with Intellisense, I have found this useful for comments mostly.</p>
<h3>Transposing Words (CTRL + SHIFT + T)</h3>
<p>Beside the occasional typo writing comments, this is handy when after refactoring a function signature I have changed the order of the parameters.<br />
Suppose you have for example you call a function in the following way:</p>
<p><code>calculateVat(price, percentage)</code></p>
<p>if for whatever reason <code>calculateVat</code> signature has changed so that the percentage comes first, you just need to put the cursor on <code>price</code> or between the two words and pressing CTRL + SHIFT + T you&#8217;ll have the following:</p>
<p><code>calculateVat(percentage, price)</code></p>
<h3>Transposing lines (ALT + SHIFT + T)</h3>
<p>I use the following formatting to wrap long function signauters across more lines:</p>
<pre class="brush:csharp">
public void AddEmployee(
    string name,
    string surname,
    string address,
    string homePhone,
    string mobilePhone,
    string email)
{
   // implementation here
}
</pre>
<p>Suppose that I decide that I want to reorder the parameters such that the mobilePhone comes before than homePhone, for whichever reason. I just need to place the cursor somewhere on the line of &#8220;homePhone&#8221; and the two lines will swap. To remember which is the direction of swapping, my mnemonic is that the line where the cursor is will <em>fall</em>.</p>
<pre class="brush:csharp">
public void AddEmployee(
    string name,
    string surname,
    string address,
    string mobilePhone, // this line has moved up
    string homePhone,  // this line has moved down
    string email)
{
   // implementation here
}
</pre>
<p>This is especially useful if you have more overloads of the same function where you need to update the order of the parameters in each of them. It&#8217;s certainly quicker than a copy&amp;paste tecnhique.</p>
<p>If you need to move one line of more than one position down, just keep pressing the ALT + SHIFT + T combination and the line will keep falling down (the cursor automatically stays in the line that is moving).</p>
<p><!-- AddThis Button BEGIN --></p>
<p><a href="http://www.addthis.com/bookmark.php?v=250"><img style="border:0;" src="http://s7.addthis.com/static/btn/lg-share-en.gif" alt="Bookmark and Share" width="125" height="16" /></a></p>
<p><!-- AddThis Button END --></p>
<div id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:e6ceeafa-fe5c-4bd6-a48d-325da43e5abc" class="wlWriterEditableSmartContent" style="display:inline;float:none;margin:0;padding:0;">Technorati Tags: <a rel="tag" href="http://technorati.com/tags/Programming">Programming</a>, <a rel="tag" href="http://technorati.com/tags/visualstudio">VisualStudio</a></div>

]]></content:encoded>
			<wfw:commentRss>http://stefanoricciardi.com/2009/08/13/more-visual-studio-2008-shortcuts-trasposing-characters-words-and-lines/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

