There is a good plugin to manage code snippets:
SnippetPlus
.NET 3.5 Required! Code snippet and Surround With plugin
for Notepad++. Write snippet name and
replace it with real code or select
some text and surround it with
something like IF,TryCatch,Table,Div
or whatever.Will give you hint if you
don't remember the snippet name Note
that the latest version may be shown,
even though you have an older version
installed. Reinstall to ensure you
have the latest version.
Author: Rajesh Kumar
Homepage: http://sourceforge.net/projects/snippetplus/
You can install it from Notepad++ Plugin Manager, and activate dock by clicking the black m-like symbol in the toolbar; then select one of the bundled snippets and paste it to editor by double-clicking it.
For example, if you have a Visual Basic file and you need to include a try/catch block which contains an if-elseif-else structure, you must follow these steps indicated in the image:
- Put your cursor where you want the new code snippet to be at, then activate dock from toolbar: this will open the docked dialog marked in yellow.
- Double-click the option
ifelseif
in the Snippets section of the dock: this will insert the code block marked in blue.
- Select all the code you want to be inside the try/catch block and Double-click the option
TryCatch
in the SurroundWith section of the dock: this will replace the selected code with all the code block marked in red.
If you want to modify existing snippets or include yours, use the GUI editor:
Click the snippet you want to modify/delete: it will be shown at right. The active section (either Snippets or SurroundWith) is highlighted with a dark red background:
You can add custom snippets too: just select the proper language and click any snippet from the section you want the new snippet to belong (either Snippets or SurroundWith), then write the name of the new snippet you want to create (e.g. sample): the button Modify will change to Add New
You can insert snippets to documents also by using keyboard shortcut Ctrl+Shift+ENTER:
- You can write directly snippet name and then press keyboard shortcut, or
- You can invoke popup pressing keyboard shortcut, and then pressing keyboard shortcut again to replace snippet name with snippet content.
Notes:
- This plugin keeps snippets (including custom ones) between restarts.
- Important Note: If you add/modify/delete snippets, only after a restart of Notepad++ the changes will be applied (including contents of lists at sections Snippets and SurroundWith). Be careful with this to not duplicate or add incomplete snippets.
- To apply code highlighting for language you're working, just select it from the menu language as is done traditionally:
- The code snippets shown on Ctrl+Shift+ENTER menu, depend on the language highlighting currently applied to the document. The only code snippets shown globally are whose belonging to category GENERAL.
I hope this information will be helpful for you.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…