There is a problem with snippets, though. Most of the snippets come with replacable parameters. For example, if you try the for snippet in C#, there will be two replacable parameters. One for the index variable (default value is i) and the length variable. Even if you change these parameters for your requirements, the highlighting will be there until you close the file. Lot of people get irritated by this behaviour and some decides not to use the code snippets altogether.
Visual Studio 2008 comes with a solution to this problem. There are Show Snippet Highlighting and Hide Snippet Highlighting options. By default, only the last snippet inserted will be highlighted. If you want to highlight all snippets inserted since the file is opened, you can right click in code editor and select Show Snippet Highlighting. If you select Hide Snippet Highlighting, all highlightings will be hidden.
However, I can't find this feature in C#, even though MSDN says it is available. Moreover, show and hide snippet highlighting feature is not available in Visual Studio 2005. In those cases what we can do? Do we need to close and open a file each time we insert a snippet?
No, there is an easy and simple solution. Eventhough it is that much simple, I took some time to figure it out. Here is the solution.
- Cut the code lines, which include snippet highlighting.
- Paste it again.
Hope it helps some one.
No comments:
Post a Comment