Showing posts with label Visual Studio. Show all posts
Showing posts with label Visual Studio. Show all posts

Saturday, January 11, 2025

Using Visual Studio Snippets and ReSharper Options

Resolving Visual Studio Snippets Conflict with ReSharper Templates 🔧🔨

ReSharper can indeed override or conflict with Visual Studio's built-in snippet functionality because its template system takes priority. Here's how you can manage this situation and use both effectively:


✔️ Option 1: Prioritize Visual Studio Snippets

If you prefer using Visual Studio's snippets over ReSharper's templates, you can adjust the ReSharper settings:

  1. Disable ReSharper Templates Temporarily:
  • Go to ReSharper > Options.
  • Navigate to Code Editing > Templates > Live Templates.
  • Uncheck the templates that conflict with Visual Studio snippets, such as prop, for, etc.
  1. Use Explicit Visual Studio Snippet Insertion:
  • Type the snippet shortcut (e.g., prop) and press Tab twice to trigger the Visual Studio snippet explicitly.
  • Alternatively, right-click in the editor, select Insert Snippet, and choose the desired snippet.

✔️ Option 2: Customize ReSharper Templates to Mimic VS Snippets

If you like ReSharper's template system but miss certain Visual Studio snippets, you can add similar functionality to ReSharper:

  1. Create a New ReSharper Template:
  • Go to ReSharper > Tools > Templates Explorer.
  • Click the New Template button.
  • Define a template name, shortcut (e.g., prop), and the desired code.
  1. Example: Create a Property Template:
  • Template Shortcut: prop

Code template example:

private $TYPE$ $fieldName$;
public $TYPE$ $PropertyName$ {
   
get { return $fieldName$; }
   
set { $fieldName$ = value; }
}

  • Add template parameters ($TYPE$, $fieldName$, $PropertyName$) as required.
  • Save and test it in your editor.

✔️ Option 3: Use Both Snippets and Templates

If you want to keep both ReSharper and Visual Studio snippets functional, use specific shortcuts to separate their behavior:

  1. Unique Shortcuts for Snippets and Templates:
  • Change Visual Studio snippet shortcuts to something unique:
  • Open Tools > Code Snippets Manager.
  • Select a snippet and update its shortcut to avoid conflicts (e.g., change prop to vsprop).
  • Now you can use vsprop for Visual Studio snippets and prop for ReSharper templates.
  1. Invoke Snippets Explicitly via Menus:
  • Right-click and choose Insert Snippet or use the menu shortcut for Visual Studio snippets.
  • Use ReSharper's shortcuts for its templates.

✔️ Option 4: Temporarily Disable ReSharper

If you frequently need Visual Studio snippets in certain projects:

  • Disable ReSharper for Specific Sessions:
  • Go to Tools > Options > Environment > Keyboard.
  • Assign a shortcut to the command ReSharper_Suspend and ReSharper_Resume.
  • Use these shortcuts to toggle ReSharper when you need Visual Studio snippets.

This balance lets you enjoy the best of both worlds: ReSharper's advanced templates and Visual Studio's snippets. 🚀

Wednesday, November 27, 2024

Visual Studio Productivity Keyboard Shortcuts

I give credit to GitHub Copilot for this recommendation question.  I followed my curiosity and found it worth posting for myself or anyone else who finds it useful.

Here are some of the most common keyboard shortcuts for efficient coding in Visual Studio 2022:

General Shortcuts

• Ctrl + Shift + P: Open the Command Palette

• Ctrl + ,: Quick Open (Navigate to a file)

• Ctrl + Shift + N: New Project

• Ctrl + O: Open File

• Ctrl + S: Save

• Ctrl + Shift + S: Save All

• Ctrl + F4: Close Document

• Ctrl + Shift + F4: Close All Documents

Editing

• Ctrl + X: Cut

• Ctrl + C: Copy

• Ctrl + V: Paste

• Ctrl + Z: Undo

• Ctrl + Y: Redo

• Ctrl + K, Ctrl + C: Comment Selection

• Ctrl + K, Ctrl + U: Uncomment Selection

• Ctrl + D: Duplicate Line

• Ctrl + K, Ctrl + D: Format Document

Navigation

• Ctrl + -: Navigate Backward

• Ctrl + Shift + -: Navigate Forward

• Ctrl + T: Go to All

• F12: Go to Definition

• Ctrl + F12: Go to Implementation

• Shift + F12: Find All References

• Ctrl + K, Ctrl + N: Go to Next Bookmark

• Ctrl + K, Ctrl + P: Go to Previous Bookmark

Debugging

• F5: Start Debugging / Continue

• Shift + F5: Stop Debugging

• F9: Toggle Breakpoint

• F10: Step Over

• F11: Step Into

• Shift + F11: Step Out

Search

• Ctrl + F: Find

• Ctrl + H: Replace

• Ctrl + Shift + F: Find in Files

• Ctrl + Shift + H: Replace in Files

Refactoring

• Ctrl + .: Quick Actions and Refactorings

• Ctrl + R, Ctrl + R: Rename

• Ctrl + R, Ctrl + G: Extract Method

These shortcuts can significantly enhance your productivity by allowing you to perform common tasks quickly without taking your hands off the keyboard.