How to: Creating Code Snippets for Visual Studio 2005/2008
Code Snippets was one of my favorite "new features" in Visual Studio 2005 and has continued to be in Visual Studio 2008. If you've never used them, what they are (simple explanation) is a macro-capability built into the Visual Studio IDE. They allow you to type single/multiple key strokes to define blocks of code. So imagine: If I want to open a database connection, adapter, create a dataset, and fill it. I could type the 5+ lines of code each time I have to do this (which is often) or I could just type something like "DataSetCode" and hit the enter button, and all of the code that I would normally hand write each time, would show up in the IDE (like a Macro). It even has the ability to prompt me for pieces like the dataset name, connection string pieces, etc., that might vary each time I write my code.
Great feature! There are some already built in to Visual Studio, others that you can download.
If you want to learn how to build your own, check these links out (taken from this MSDN article)
- How to: Create a Basic Code Snippet (Describes how to create a simple code snippet.)
- How to: Create a New Snippet with Imports and References (Explains how to add Imports and References elements to Visual Basic code snippets.)
- How to: Create a New Snippet with Replacements (Explains how to add customizable literals and objects to code snippets.)
- How to: Create Code Snippets for XML Files (Explains how to create a code snippet for XML files.)
BTW, if you don't like hand writing XML, then you might want to download this free Code Snippet Editor called: "Snippy": Click here to access the download
~ Robert Shelton
'Development Tools' 카테고리의 다른 글
Visual Studio 2010 빌드 오류 <error FTK1011> 해결 방법 (0) | 2010.06.24 |
---|---|
웹 서버에서 디버깅을 시작할 수 없습니다. 웹 서버와 통신하는 동안 인증 오류가 발생했습니다. (0) | 2009.10.27 |
[Visual Studio]프로젝트 파일을 소스세이프에 추가할 때 (0) | 2009.07.07 |
Visual Studio's Web Deployment Projects (0) | 2009.05.06 |
VS 2005 Web Deployment Projects (0) | 2009.05.06 |