下面是一个写在AutoHotkey的:
#NoEnv
SetWorkingDir %A_ScriptDir%
SendMode Input
#InstallKeybdHook
#UseHook On
(::
if GetKeyState("ScrollLock","T")
{
sel := GetSelection(1)
if sel
PasteText("(" sel ")")
else
Send (
sel := ""
}
else
Send (
Return
"::
if GetKeyState("ScrollLock","T")
{
sel := GetSelection(1)
if sel
PasteText("""" sel """")
else
Send "
sel := ""
}
else
Send "
Return
'::
if GetKeyState("ScrollLock","T")
{
sel := GetSelection(1)
if sel
PasteText("'" sel "'")
else
Send '
sel := ""
}
else
Send '
Return
{::
if GetKeyState("ScrollLock","T")
{
sel := GetSelection(1)
if sel
PasteText("{" sel "}")
else
Send {{}}
sel := ""
}
else
SendRaw {
Return
[::
if GetKeyState("ScrollLock","T")
{
sel := GetSelection(1)
if sel
PasteText("[" sel "]")
else
Send [
sel := ""
}
else
Send [
Return
<::
if GetKeyState("ScrollLock","T")
{
sel := GetSelection(1)
if sel
PasteText("<" sel ">")
else
Send <
sel := ""
}
else
Send <
Return
GetSelection(wait = "")
{
ClipBack := ClipboardAll
Clipboard := ""
Send ^c
if wait
ClipWait 0.05
Selection := Clipboard
Clipboard := ClipBack
Return Selection
}
AutoHotkey的安装后,这段代码保存到一个文本文件,重命名扩展.ahk并运行它。它需要打开Scroll Lock才能使代码正常工作。
该代码从http://www.autohotkey.net/~Vifon/修改为:
- 包含 '和<
- 写入',” <,{[(而不是 '', “”,<>,{} ,当没有文本被选中时,[],()
这确实不错。 – 2009-11-14 14:06:58
这在日食中是不可能的。但是Eclipse支持自动报价关闭。 – Secko 2009-11-18 00:46:45