Snippets everywhere!
Snippets are small chunks of code usually used again and again in different settings.
For instance, in order too see what a variable holds in PHP you write
|
|
And if you want it to look good (indentation on arrays & objects), you add a pre, and let's exit the program afterwards (with die)
|
|
Now we have in our hands a pretty long,
albeit useful, piece of code (one might say, a snippet ;)).
How do we quickly use it without writing it over and over again?
Depends on the program you use to write code with.
Notepad++:
The best plugin I found for snippets has got to be FingerText.
It's intuitive, simple, but still quite powerful.
To configure a snippet all you have to do is install the plugin,
go to Plugins -> FingerText -> Create Snippet from Selection.
The plugin explains it all pretty well, after choosing the triggertext (for instance, dbg),
simply type it wherever you want the snippet to appear and press the TAB key.
Mouse Cursor: $[0[]0]
NetBeans:
Under Tools -> Options -> Editor -> Code Templates
Select the language you want to use the snippet under, and write it.
Mouse Cursor: ${cursor}
Eclipse:
Go to Window -> Preferences -> Web/Java/CSS/... -> Editor -> Templates.
Click New... and add your snippet.
Mouse Cursor: ${cursor}
Depending on the language, you could (and should) write snippets for anything you often write.
For HTML it might be a Table, Forms, List, etc.
For most programming language it might be for & while loops, if-then-else, exceptions, etc.
It's important to identify whatever it is you do many times over, and make it as short as possible.
This is a good tip for computer use in general, whether it is with Snippets or Key-Shortcuts.