Code snippets with AutoHotkey
If you haven’t used AutoHotkey before, you should check on YouTube what it can do or try sample scripts from their website.
I think AutoHotkey is great productivity tool and my script is longer every day. One of the things I use AutoHotkey for is for code snippets.
I never really tried code snippets in Visual Studio, but I found code templates in Eclipse really useful and easy to define and use.
With this AutoHotkey script I came close to what I was used to in Eclipse:
; * XML ::<wo:: PasteText("<word id=""Clip0"">`r`n <slo></slo>`r`n <eng>Clip0</eng>`r`n</word>") Return ; * PHP ::-br::<br /> ::-ph:: PasteText("<?php`r`n`?>") Return ::-sc:: PasteText("<script>`r`n</script>") Return ; * VISUAL STUDIO ::#ef:: PasteText("#if r2010`r`n#else`r`nClip0`r`n#endif") Return ; PasteText function PasteText(text) { CurrentClip=%Clipboard% StringReplace, replaced, text, Clip0, %Clipboard%, All Clipboard=%replaced% Send, ^V Sleep, 50 ; Don't change clipboard while pasting! (Sleep > 0) Clipboard=%CurrentClip% ; Restore original ClipBoard Clip0= }
In the above code, the text ‘Clip0’ is replaced by clipboard content, so in case if I type ‘<wo’ and I have text ‘Hello world!’ in clipboard, this is the resulting text:
<word id="Hello world!"> <slo></slo> <eng>Hello world!</eng> </word>
Advertisements