Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm looking for a simple software which would do this:

When I type in something like dbs and hit tab or enter, it will replace dbs with $this->db->set() in the program that I typed it in.

It needs to allow for multiple such shortcuts/templates. If there's a way to only put in these shortcuts in a specific program, or to dictate where the cursor should be put, that would be an added bonus.

The reason I want this, is because I'm too used to code templates in Netbeans, however in the latest version, they're broken for me.

Thanks.

share|improve this question
    
Operating system? –  Bob May 21 '12 at 1:29
    
@Bob Windows XP ---- –  Click Upvote May 21 '12 at 2:08
add comment

2 Answers

You can do this with Hotstrings in AutoHotkey. For example:

::dbs::$this->dbs->set()

Unless the asterisk option is in effect, you must type an ending character after a hotstring's abbreviation to trigger it. Ending characters initially consist of the following: -()[]{}':;"/\,.?!`n `t (note that `n is Enter, `t is Tab, and there is a plain space between `n and `t). This set of characters can be changed by editing the following example, which sets the new ending characters for all hotstrings, not just the ones beneath it:

#Hotstring EndChars -()[]{}:;'"/\,.?!`n `t

The default EndChars includes tab and enter, but you may wish to remove some of the ending characters. The defaults appear to be chosen specifically for programmers.

You can make it program specific with #IfWinActive, for example:

#IfWinActive ahk_class Notepad

#IfWinActive affects all hotstrings defined after the directive, as described at the linked page. The ahk_class can be found with AutoIt3 Window Spy, a program included with AutoHotkey. You can also use window title, partial title, pid, etc.

share|improve this answer
add comment

You may be able to use AutoHotKey (http://www.autohotkey.com/) for this. You could listen for "d" "b" "s" "|" and replace it with "backspace" x 4, "$this->db->set()" etc. For example.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.