Windows and Mac… be a Text Editor power user…
Ever open your text editor just to paste the clipboard contents? Maybe to view, edit, or strip formatting? Or how about opening notepad just to type a quick note, thought, or save some text? I find I’m constantly doing these throughout the day. To make this snappy, here’s how to make a global PC or Mac keyboard shortcut to open the editor with the clipboard contents (and automate away the save dialog).
What You Get (for Windows, Mac OS read below)
- Win+W opens Notepad with an empty temp file
- Win+Shift+W opens Notepad with the clipboard contents in a temp file
- Then when closing Notepad the temp file is automatically saved. Only if it’s one of these temp files, to get rid of that pesky “Do you want to save this file?” dialog. If you want the text in something other than a temp file, just use Save As. Space is cheap so it’s fine to have plenty of these temp files. It also gives a way of searching for past text.
Watch it in Action
Supported Editors
The script includes support for Notepad2, Notepad2-mod, Sublime Text 2 (my fav), Notepad++, and UltraEdit. Windows notepad.exe and SlickEdit don’t work as the file name in the save dialog isn’t available to automation.
All uber-geeks have their favorite text editors, so to modify for another editor:
- Have the editor registered to open .txt files. Most other editors have some tools options setting for it or right-click on a .txt file and select “Open with” > “Choose default program…”.
- Update the dialog matching info, title and dialog contents regular expression, to match that unique editor. Use the AU3_Spy.exe tool that comes with AutoHotKey to get the contents of your editor’s save file dialog.
The AutoHotkey Script
This uses a handy little AutoHotkey (a free, open-source, windows scripting tool) script. Save the script and run it. To keep active on boot, make a shortcut to this script in the Start Menu > All Programs > Startup folder. It uses a little .NET app EditClipboardText (download or source) to put the clipboard contents into a file and open the file since encoding with AutoHotkey is tricky.
(if the code isn’t showing just above this line, you can get it here: https://gist.github.com/4064637)
Doing this in Mac OSX
Use your favorite global hotkey app to launch this script, such as Quicksilver, Sparkle, or Alfred Powerpack. Remember to mark the file as executable, sudo chmod u+x ~/scripts/cliptext.rb The dialog automation part is tricky (I don’t know how to automate MacOSX dialogs, even if it’s possob), but not needed if you use Sublime Text 2 and set the save_on_last_focus setting.
(if the code isn’t showing just above this line, see it here https://gist.github.com/4315822)
Update 1/2/12: Added UltraEdit, Notepad++, and Sublime Text 2 dialog automation. Fixed AutoHotkey script. Added EditClipboardText tool. Added video example.













Your script has a dependency on EditClipboardText.exe. Is this a compiled version of the ruby script at the bottom of the article?
Josh, thank you for the feedback. Looks like there were a few pieces that needed updating. They’re fixed now. cheers
Thanks. New version works great.
The MakeTempFile() function also appears to be a dependency.
In the Ruby script I needed to replace ‘ftools’ with ‘filetools’ and ‘FileUtils.makedirs’ instead of ‘File.makedirs’.
-Radi