Brendan Enrick

Daily Software Development

Windows 7 Keyboard Tips

Anyone who would be reading my blog probably already knows that you can use the keys [alt] + [tab] to switch between programs running on your windows system. This functionality has been around for a while. There are a lot of new and beneficial keyboard shortcuts that you might not know. Some came with Windows Vista and some with Windows 7, but after some time using the new Windows 7 interface I deem a lot of these shortcuts to be essential.

Opening Applications Using the Keyboard in Windows 7

Opening an application takes a good amount of time if you don’t have quick easy access to a lot of applications. I believe keyboard access is essential. Certainly I use quick-launch still, but I use it in combination with a keyboard in Windows 7, because of a slight deficiency in the new taskbar.

Win-Search

Searching for the application is a pretty good one if you haven’t set the app as a quick-launch one. Just press the [Win] key and start typing. Windows will display the results grouped in the start menu and you’ll be able to select the one you want to open. This is quick, but there are faster solutions.

Win-Number

The quick-launch bar is faster than most people realize. This isn’t new to Windows 7, but is relatively unknown as far as I can tell. Try holding down the [Win] key and press the number starting from the left of the app you want to run. For the application closest to the start menu you would hold [Win] and press [1]. In my case 1 opens Internet Explorer 2 opens FireFox and 3 opens Chrome. The order doesn’t really matter, but the point is that I know the numbers for the apps I use most often and I don’t change those numbers so they’re easy to use.

Win-Shift-Number

Just like using Win-Number you can also hold [Win] and [Shift] and press the corresponding quick-launch number to open another instance of an application that is already running.

 

Quick-Launch

Someone is probably wondering why quick-launch is in this post talking about using the keyboard. Well it is here because quick-launch now requires the keyboard if you want to quickly and easily open a second instance of the same application. Since the task-bar and quick-launch are combined now if we click on an application that is already open all it does is bring that app to the front of the screen. To open another instance just hold the [Shift] key when you click on the icon and you’ll get a new instance.

Ctrl-T

This is another quick-launch related shortcut. By holding [Ctrl] and clicking [T] you will be selecting quick-launch items. When you get the app you want to open just click [Enter]. If the application is already open then you can use the shortcut I mentioned before this one in combination. Once you have the app selected just hold [Shift] and click [Enter] while selecting the desired application.

Switching Windows Using the Keyboard in Windows 7

We “multitask” when we use computers or at least we think we do. Since we don’t really multitask we get stuck context switching all the time. This can really drain our ability to get things done, so we should make sure the switch happens quickly. There are plenty of shortcuts in place to make this easier.

Alt-Tab

By holding down the [Alt] key and pressing the [Tab] key we are able to browse through the set of running applications. These applications will be displayed with thumbnails of what the window looks like so we can decide if it is the one we want.

Win-Tab

Similar to the previous one, holding the [Win] key and pressing the [Tab] key will allow you to cycle through the running windows also. This garners a different view. Instead of having thumbnails in a rectangle in the center of the screen we instead get a sort of diagonal cascading line of windows that have been shrunken a little bit smaller so they can line up. This view in my opinion is kind of neat, but I still tend to use Alt-Tab. If you expect to often have difficulty differentiating applications from a thumbnail then this view is probably better for you.

Ctrl-Tab

Those familiar with tabbed applications know this common method of switching between tabs. This is available in a large number of Windows 7 applications. Hold [Ctrl] and press [Tab] to switch between tabs in an application. This functionality exists in most web browsers and a handful of other applications.

Ctrl-T

Windows 7’s new taskbar has added a very new interface to Windows. To select apps in the task bar you can hold [Ctrl] and press the [T] key which will select the applications in the taskbar. Once on the desired application simple press [Enter] to select that app. If only one window exists for that app right now it will open. If there are more then you will then use the left and right arrow keys to select the one you want and then press [Enter] again to bring it to the front.

Win-Number

This is one of the ones I mentioned for opening an application, but if the app is already open using it will select the application. Just hold [Win] and press the corresponding number of the application. Also if you want to switch between windows of that application just press the number multiple times until the correct one is selected.

There is another window switching option I really want in Windows 7 and that is the ability to switch between the same type of application. By this I mean that if I have an Explorer window open I want to be able to switch between the current explorer windows with an easy works-for-everything keyboard shortcut. I understand that the ones I’ve mentioned work, but they are clunky if I know that I want to restrict to just one application type. Win-Number seems like it is the best, but some applications I don’t keep pinned to the taskbar so I don’t know their number.

If you know any more cool shortcuts or know of a way I can switch easily between the same application please post them in the comments.

Daily Dev Speedup - Commenting and Uncommenting Code Quickly

Visual Studio as well as many other applications which know what language you're using are able to do a lot of the little shortcuts for common tasks like commenting and uncommenting code. This can help speed things up a great deal since you can usually do many lines at a time. Also you don't have the context switching to go to a mouse to click the button.

CommentButtons

Instead of clicking that button just type.

[Ctrl] + K + C - Comments out code

[Ctrl] + K + U - Uncomments code

It is not the best of keyboard shortcuts, however, it lets you avoid the context switching of moving to the mouse and when commenting out multiple lines it is quite quick. This will work in code such as C# as well as with the markup of XML-based languages.

Daily Dev Speedup - Use Lightweight Tools for Lightweight Work

Everyone is always trying to use the best possible computers to do their jobs. Developers buy high performance machines so they can write code faster. Some improvements can be made to your development speed without going and spending large sums of money amassing expensive tools and machines.

As any craftsman will tell you, "you need to have the right tool for the job". A lot of times there are quick queries that we need to write to check bits of data and such. If this is what you're doing, it is sill to open up SQL Server Management Studio just to check this. The overhead of opening up and application and using it will have you wasting plenty of time. Use a tool like LINQPad, so you have a lightweight application you can easily open and work with.

If you need to make a code change to a config file or some very minor edit to a text file of a variety of languages I recommend using a lightweight text editor like Notepad++. This will save you a lot of time over opening Visual Studio, and it is much more advanced than Notepad. It has a good amount of advanced features and isn't a full-featured IDE like Visual Studio.

Using these lightweight tools in combination with the heavy-duty tools like SQL Server Management Studio and Visual Studio will make things a lot easier.

Daily Dev Speedup - Using Visual Studio Snippets

In Visual Studio there are code snippets which can be used with auto-completion. These are a lot of the common structures used by developers when writing code. They are customizable using Visual Studio, but I find it much easier to use editors like Snippy. So if you were not using snippets because one of them was not exactly the way you wanted it to be, give a snippet editor a shot.

I highly recommend creating your own snippets as well as customizing them. I for example use one to create tests. I type 3 letters hit tab and type the name of the test method. This saves me the time of typing the attribute as well as "public void" and some curly braces every time I write a test. Yes, I know that a lot of these are simple little things, but trust me when I say that they all add up into faster development. How do you think all of the visual studio add-ins make money? They allow for a lot of little speed boosts which keep developers coding faster.

Daily Dev Speedup - Working With Words

A lot of applications allow you to work with a group of text at a time. For the purposes of this post I'll call them "words". When I say a lot of applications this includes the powerful IDE called Notepad. This cool trick can be applied in a lot of different places. I am sure you'll figure out some interesting uses for this.

The key (literally) to achieving this productivity from working with words is the Ctrl key. By holding it in combination with other keys we can work with words. The three main things I want to discuss when working with words are: moving from over a word, selecting a word, and deleting a word. As you can probably guess to move through a word you use Ctrl with an arrow key. To select a word you hold Ctrl as well as Shift while using the arrow key. To delete a word you can use Ctrl  in combination with Delete or Backspace. (Yes, I lumped delete and backspace together even though they are technically separate operations.)

Here is a demonstration in Visual Studio showing how to move over words followed by select words followed by deleting words.

Daily Dev Speedup - Selecting and Dragging Lines

Yesterday I posted about how important it is to use keyboard shortcuts and tools to help you write code faster. Any developer working towards self-improvement should be looking not only into how to program better but also how to program faster.

Today I'll start by mentioning a pretty easy one. If you use Visual Studio I really hope you keep line numbers on. I could probably claim that as the first tip since it does speed things up. This is especially true when collaborating with someone when they can say the line number about which they are speaking. For the real tip I'll be mentioning here you do not need to have the line numbers enabled, but they give you more surface area to click on.

This actually works in a lot of programs, but I'll explain how to use it in Visual Studio. All you need to do is click on the left hand edge of a line and you will be able to select the whole line (this includes the new line at the end). If you click and drag you can select multiple whole lines easily.

Along with this trick you are also able to easily select any text that is highlighted and you can click and drag it to a new location. These work well in combination because rearranging lines becomes very easy. Moving any code at all in fact becomes very easy.

Below is a demonstration of what can be done by clicking and dragging text around and highlighting using the line numbers.

Productive Typing

In software development it is very important that you type quickly. Now some people are going to be thinking that simple words/minute is important. I agree that it is important to be able to type quickly in general while programming. There are other aspects to this as well. Now consider if you have two programmers and one types twice as fast as the other. Which one is more valuable to the company? So I might have oversimplified this, but I would assume most people who go and read blogs are probably trying to improve their skills as a developer and if you're not considering your programming (typing) speed then you're not considering enough.

As a said moments ago, I am not going to talk words per minute. That isn't always relevant since we're not always typing words. Ours are a lot of the same words as well as a lot of symbols. It isn't normal typing. What I am going to say is that developers need to be taking advantage of keyboard shortcuts and snippets; from the standard ones which work in many applications down to Visual Studio specific shortcuts. A lot of developers use add-ins like CodeRush and Resharper to increase their development speed.

Program Agnostic Shortcuts

Starting simply, I will talk about one of the simplest tricks which will help you everywhere. Use your Home and End keys religiously. They will help you tremendously getting you to different points on a line very quickly. This is a simple one that everyone can remember. The extra trick to know here is that you can hold the Ctrl key and it will jump you to the top or bottom of the page.

So I've just mentioned the Ctrl key I will say that it is the most useful key for shortcutting. I'll now go on a rant of the non-VS specific tricks in can help you with.

Everyone should know copy (Ctrl + c), cut (Ctrl + x), and paste (Ctrl + v) There are plenty of other ones dealing with that key that are also very simple. I can't spend the time talking about all of those. Some of the lesser known ones are also important. For example. Everyone knows that you can use the arrow keys to move the cursor right, left, up, and down. If you combine the left-right movement with Ctrl you will notice that the cursor jumps "words". What consists of a word is interpreted differently depending on the application, but try it out in them and you'll see how useful it is. It will save you a lot of time.

Combine this with the shift key for Ctrl +  Shift + [Direction] and you'll be able to select these words very quickly. This is useful for replacing and changing test or simple copying a variable name. Whatever you've got to do. When you're deleting, don't waste time with it. Combing Delete and Backspace with Ctrl will let you delete "words" very quickly.

Visual Studio Specific Shortcuts

I certainly can't cover all of the shortcuts here, but there are a lot of them. For example if you need to make an auto-property all you need to do is be in the context of a class and type "prop" and then hit Tab. You will get a snippet for your property. If you need a for loop you better not waste time writing it. Most for loops are the same, so just type "for" and hit tab. These are all of your snippets and you can customize and create your own. This is easy and there are tools for editing snippets.

You should also look into the different refactorings that Visual Studio is able to do. Right click and choose Refactor from the context menu and you will see a bunch of options available to you.

Also the most powerful shortcut specific to Visual Studio is Ctrl + . which is context sensitive. For example if you change a name pressing that afterward will allow you to do a rename. There are a lot of other context specific options such as including using statements at the top of the file after adding an type which requires one.

Other Tools

If you're really looking to speed up you should look at some of the third party add-ins to visual studio. Resharper and CodeRush are a couple of the popular commercial products. I currently use Resharper, but I've also lost a coding competition to someone using CodeRush. They're great and integrate a lot of what you need. These tools also come with keyboard mapping files which you can print and have a reference of the shortcuts to speed the learning process.

Resharper for example has a lot of shortcuts for navigating. Ctrl + n lets you search for different types and jump directly to them. Ctrl + Shift +  n lets you jump to files. The searching is fairly smart. The tool also adjusts your intellisense so that it pays attention to campital letters. For example if I were going to type "SuperSpecialStaticClass" I could type "SSSC" and that would be the top of my intellisense. If there were a class named "SlightlySpecialStaticClass" I might have to type "SuSSC" or just go down to the next choice in intellisense.

Rather than spend much more time talking about third party tools I will just say that there are a lot of them out there. They're not very expensive and they will make your time spent be more productive.

Make sure you stay up to date on all of the tools and shortcuts available to you.