Visual Studio: Toggle Outlining

Outlining is the Visual Studio jargon for what is more commonly called code folding in other editors or IDEs. There are a lot of keyboard shortcuts for various outlining operations. I just remember and use one shortcut: Ctrl+M+L. This shortcut toggles outlining for the currently open file. That is, it folds all the code or unfolds all the code in the file.

I typically toggle the outlining to step back and get a picture of the functions in the file and where they are placed in the file. Sometimes I am looking for a certain function, so I fold all the code to find the function, then place the cursor at the function name and unfold all the code. The cursor remains at the line where it was placed and I am now in the code of that function. Pretty useful! 🙂

Tried with: Visual Studio 2010

Visual Studio: Delete Word or Whitespace to Right of Cursor

Ctrl+Delete is a very useful keyboard shortcut to remember while using Visual C++ or any other language with Visual Studio. It deletes the word to the right of the cursor.

  • If the cursor is at the beginning of a word when Ctrl+Delete is pressed, then that entire word is deleted.
  • If the cursor is in the middle of a word when Ctrl+Delete is pressed, then the portion of the word to the right of the cursor is deleted.
  • But, this shortcut is most useful with whitespace. All whitespace to the right of the cursor is considered to be a word. So, by placing the cursor in the middle of whitespace and pressing Ctrl+Delete removes all the whitespace to the right of the cursor up to the next alphanumeric character. This is very useful when aligning text or just removing a lot of spaces. Surely easier than pressing Delete a lot of times! 🙂

Tried with: Visual Studio 2010

Windows 7: Keyboard Shortcut for Battery Meter


In Windows 7, I typically hide all the system tray icons, including the battery meter of the laptop. These are information which I want to see when I want to and not constantly hog the display and my attention. So, if the battery meter is hidden away inside the system tray, how to see the battery meter when I want to without using the mouse?


There does not seem to be any keyboard shortcut for the battery meter. However, Windows 7 has a super-useful Windows Mobility Center dialog that is enabled on laptops. It displays the battery meter and a few other statuses.

The keyboard shortcut to bring up this dialog is Win+X. Press Esc or Win+X to dismiss the dialog once you have noted your battery level.

Visual Studio: Zoom in the Editor

One of the neat features in Visual Studio 2010 is that zooming into and out of text is baked into the editor. Using the mouse, zoom can be applied by rolling the mouse scrollwheel while keeping the Ctrl key pressed. Using the keyboard, the same can be achieved by pressing Ctrl+> or Ctrl+< to zoom in and out.

If you are stuck with Visual Studio 2008, do not worry, it has this feature hidden away in a dark corner! Open Tools → Options and drill down to Environment → Keyboard. The commands you are looking for are Macros.Samples.Accessibility.DecreaseTextEditorFontSize and Macros.Samples.Accessibility.IncreaseTextEditorFontSize. Set keyboard shortcuts for these two commands and you are done! I like to set them to the same as in Visual Studio 2010: Ctrl+< and Ctrl+>.

In Visual Studio 2010, the zoom increment can be as small as 1%. I am guessing this is because it renders the editor using WPF. In Visual Studio 2008, the zoom increment is 10%, which I think is perfect and good enough! 🙂

Windows: Keyboard Shortcut to Command Prompt of Current Directory

Watching a TechEd 2011 video on Visual Studio Tips and Tricks, I was introduced to a cool keyboard shortcut to open a Command Prompt at the directory open in Windows Explorer. It is well known that this can be done by holding Shift while right clicking the mouse and choosing Open command window here.

To achieve the same using only the keyboard, press Alt+d, type cmd and press Enter. Alt+d is the keyboard shortcut in lots of Windows applications, including Windows Explorer, that puts the focus into the location bar. Type cmd in the location bar and press Enter to open a Command Prompt for the directory currently open in Explorer.

(Note: If you are using Windows with a non-English locale, this solution will not work for you. For such a situation, check out the solution offered by Airmax in the comments below.)

Tried with: Windows 7

Windows 7: Start Any Application as Administrator from Keyboard

It is well known that you can start any application as Administrator by typing its name at the start menu, right-clicking its name from the list and choosing Run as Administrator.

Charon, one of the readers of this blog, has contributed a far cooler way to start any application as Administrator:

  1. Type the name of the application in the Start menu.
  2. Use the arrow keys if needed to choose the application from the displayed list.
  3. Instead of pressing Enter, press Ctrl+Shift+Enter and the application is invoked with Administrator privileges.

This is an awesome trick to know if you like to open applications from the keyboard without using the mouse. Thanks Charon! 🙂

Visual C++: Keyboard Shortcuts

Every programmer has his favorite keyboard shortcuts. Here are mine for Visual C++, from most used to least used, with some comments:

  • Jump to definition: F12
  • Jump to declaration: Ctrl + F12
  • Jump back (from any earlier jump): Ctrl + –
    • The above 3 keyboard shortcuts are my key tools to peek into and understand any C++ code.
  • Compile currently open .cpp file: Ctrl + F7
    • Every C++ programmer knows how frustratingly slow C++ compilers are! It is faster to first compile the currently modified file and proceed with a full solution build only if this succeeds. I typically keep compiling the current file while incrementally modifying a file and do a full build only much later when that part is completely coded.
  • Build solution: F7
  • Execute with debugging support: F5
  • Execute without debugging support: Ctrl + F5
  • Add or remove breakpoint on current line: F9
  • Find in entire solution and list in Find Results window: Ctrl + Shift + F
    • The normal find (Ctrl + F and F3) only jumps to one result and the user can jump around from there. I find the listing of all occurrences in a separate window much more useful. I can see all the files where it is used and also see one line of usage in them. This is very useful to understand and refactor code.
  • Full Screen: Alt + Shift + Enter
    • Visual Studio non-editor windows take too much space and combined with the Windows taskbar, they are all huge distractions while coding and debugging. So, I always work in full screen mode and switch back to normal size only to fix compile errors. But, the above default keyboard shortcut is hard to enter without causing side-effects, since it has Enter in it. So, I map this action to Ctrl + M, Ctrl + M instead. That is, keeping Ctrl pressed and press M twice. This is the keyboard shortcut for full screen in Eclipse. I find it easier to type and remember: M → Maximize 🙂
  • Delete line: Shift + Del
    • Useful while deleting many lines of code, which happens almost all the time.
  • Add or remove bookmark: Ctrl + K, Ctrl + K
    • Easy to remember: bookmark ends with a K 🙂 I find it very useful to leave a breadcrumb trail of bookmarks on lines where I need to modify or check code.
  • Jump to next bookmark: Crtl + K, Ctrl  + N
    • To follow the breadcrumb trail of bookmarks.

Picasaweb: Keyboard Shortcuts

Keyboard shortcuts are useful for browsing through the hundreds of photos friends share in their Picasaweb albums. Picasaweb seems to be sorely neglected by Google when it comes to keyboard shortcuts. One can only move to the previous or next photo. Shortcuts to zoom in/out and pan on a photo would have been useful.

  • Next photo: Right arrow key / j / n
  • Previous photo: Left arrow key / k / p

I find the easiest to use are the left/right arrow keys to flick through the photos.