Visual Studio Shortcut Keys

This is in continuation with article 1 where I discussed about how one can be more productive with Visual Studio. In article 1, we discussed some shortcuts that helps a lot while writing and reviewing code in day to day work. While writing code we need to follow certain rules and constructs that also becomes very repetitive. For example, you are writing classes for your domain or adding properties or defining constructors or putting try block and lot more where we just need to write the code in similar pattern. Spending time in these types of codes are waste of time and energy. To see my previous article 1, here's the link:

In this article, I am going to discuss some more tricks that can insert code snippets just by few keystrokes.

  1. For creating an MVC [HttpGet] action method use mvc4 and press TAB twice.



  2. For creating MVC [HttpPost] action method, use mvcp and press TAB twice.



  3. For creating unit test class in MVC application, use test and press TAB twice.

    MVC application

  4. For creating Unit test method, use testm and press TAB twice.

    Create Unit test method

  5. For creating a region, use reg and press TAB twice.

    Region

  6. For creating static int Main (string[] args), use sim and press TAB twice.

    Sim

    my class

  7. Create auto implemented properties with 'get' accessor and private 'set' accessor using propg and press TAB twice.

    Create auto implemnted properties

  8. For creating void main method use svm and press TAB twice.

    Create void main method

  9. Create try finally block using tryf and press TAB twice.

  10. Create MessageBox.show(“”) using mbox  andpress TAB twice.

  11. Create Interface using int and press TAB twice.

  12. Create foreach() loop using fore and press TAB twice.

  13. Create do while loop using do and press TAB twice.

  14. Create for loop using for and press TAB twice.

  15. Create while loop using wh and press TAB twice.

Some other tips and tricks:

  • Open Package Manager Console using ALT + T + N and press Enter key.

  • Build the project using CTRL + SHIFT + B.

  • Open Solution Explorer using CTRL + ALT + L.

  • Open Server Explorer using CTRL + ALT + S.

  • Find the location of project, right click on project and go to open folder in file explorer, then press enter or click.

    open folde in file explorer

  • Start Visual Studio from “Run” command prompt using devenv, then click ok.

    run
  • See all errors in your document, project, or solution by using  CTRL+\,E    or       Ctrl+W,E 
  • Navigate to any file/type/member/symbol declaration by using   CTRL+T