Bookending Highlighted Text Keyboard Shortcut
October 4, 2007 12:37 PM Subscribe
I need to highlight a word, hit a combination of keys which will add text I specify before and after the highlighted word. I'm running Windows XP.
I'm trying to fix a bunch of php pages so they're register_globals OFF compliant. Essentially that means turning:
$something into $_GET['something']
Is there any software out there for Windows XP that will create a keyboard shortcut that allows me to highlight something and add the _GET[' to the beginning and '] to the end of the highlighted text?
Bonus points if I can setup multiple shortcuts so I can have one shortcut for _GET one for _POST, etc.
something will not always be the same, so a simple Search/Replace won't do the trick. I use Macromedia Homesite, so if it's got the capability of doing this already (seems like it'd be pretty similar to how it adds bold tags, etc.), that works too.
I'm trying to fix a bunch of php pages so they're register_globals OFF compliant. Essentially that means turning:
$something into $_GET['something']
Is there any software out there for Windows XP that will create a keyboard shortcut that allows me to highlight something and add the _GET[' to the beginning and '] to the end of the highlighted text?
Bonus points if I can setup multiple shortcuts so I can have one shortcut for _GET one for _POST, etc.
something will not always be the same, so a simple Search/Replace won't do the trick. I use Macromedia Homesite, so if it's got the capability of doing this already (seems like it'd be pretty similar to how it adds bold tags, etc.), that works too.
Sorry, clarification is in order - that's presuming you're okay with a "point a script at your php and let the magic happen" solution; it won't give you a keyboard shortcut.
posted by Tomorrowful at 12:45 PM on October 4, 2007
posted by Tomorrowful at 12:45 PM on October 4, 2007
How many different $somethings are we talking about here, and are there any instances of $something where it should be changed in some files but not others?
posted by Doofus Magoo at 12:52 PM on October 4, 2007
posted by Doofus Magoo at 12:52 PM on October 4, 2007
Texter from lifehacker.com should be able to do this using 'Script' mode.
posted by wannalol at 12:52 PM on October 4, 2007
posted by wannalol at 12:52 PM on October 4, 2007
Best answer: And thinking about it now, if you're willing to highlight and do the Magic Keypress everywhere it's needed, just get a keyboard macro program. The macro you want to execute when something (note: not the $) is highlighted would just be:
Ctrl-X
_GET['
Ctrl-V
']
posted by Doofus Magoo at 12:55 PM on October 4, 2007
Ctrl-X
_GET['
Ctrl-V
']
posted by Doofus Magoo at 12:55 PM on October 4, 2007
Response by poster: Doofus Magoo's method seems like it'd work. Can anyone recommend a good keyboard macro program then?
posted by backwards guitar at 12:59 PM on October 4, 2007
posted by backwards guitar at 12:59 PM on October 4, 2007
I use Notepad++ for all my development-type stuff, and it's got a macro function built into it. I've never used it before, but I just tested it with the above method, and it worked like a charm.
posted by Doofus Magoo at 1:02 PM on October 4, 2007
posted by Doofus Magoo at 1:02 PM on October 4, 2007
Let's get the mouse out of the equation. When you find instances of something, stick a placemark character (something that doesn't exist anywhere in your file) in front of it.
Now there are any number of scripting approaches that will allow you to search for the placemark character, stick a string in front of it, search for the next occuring space, and stick a second string there. Heck, you could even do it with a keystroke-recording macro in a word processor.
posted by gum at 1:04 PM on October 4, 2007
Now there are any number of scripting approaches that will allow you to search for the placemark character, stick a string in front of it, search for the next occuring space, and stick a second string there. Heck, you could even do it with a keystroke-recording macro in a word processor.
posted by gum at 1:04 PM on October 4, 2007
For macros, I recommend HotKeyboard Pro - approx 39$ IIRC
posted by mazienh at 1:33 PM on October 4, 2007
posted by mazienh at 1:33 PM on October 4, 2007
Best answer: In Macromedia Homesite 5 you can add a snippet (in one of the tabs in the left hand dock) with Start Text = _GET[' and End Text = ']. Then set a keyboard shortcut for that snippet with Options > Customize > Snippet Shortcuts. Multiple snippets is possible with various keyboard shortcuts.
I don't know if this works the same with other Homesite versions though.
posted by mnsc at 1:58 PM on October 4, 2007
I don't know if this works the same with other Homesite versions though.
posted by mnsc at 1:58 PM on October 4, 2007
Response by poster: Thanks for all your answers. I ended up using mnsc's method, but marked Doofus Magoo's as Best Answer as well, since it would probably prove useful for people not using Homesite.
posted by backwards guitar at 2:42 PM on October 4, 2007
posted by backwards guitar at 2:42 PM on October 4, 2007
Download AutoHotkey (free) and set up all the useful keyboard macros you could ever want. One of the most ridiculously handy pieces of software for Windows machines in existence! Also, as a self-development project, it appears Homesite supports regular expressions. Doing a search / replace across an entire document (or even multiple documents, if Homesite supports the operation) using a regular expression to match the pattern you've described would be a snap to anyone comfortable with regexes. Here's a good reference site for regular expressions, if you decide it's worth investigating: Regular-expressions.info.
posted by planetthoughtful at 6:41 PM on October 4, 2007
posted by planetthoughtful at 6:41 PM on October 4, 2007
Just for completeness, I'd like to mention you can get Emacs for Windows.
Emacs, as everybody knows, can do anything. M-x replace-regexp is the way to go for your problem.
posted by the number 17 at 12:47 AM on October 5, 2007
Emacs, as everybody knows, can do anything. M-x replace-regexp is the way to go for your problem.
posted by the number 17 at 12:47 AM on October 5, 2007
This thread is closed to new comments.
posted by Tomorrowful at 12:44 PM on October 4, 2007