AutoHotkey Community

It is currently May 26th, 2012, 7:49 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: May 15th, 2009, 4:56 pm 
Offline

Joined: August 3rd, 2007, 8:01 am
Posts: 555
Location: Houston, TX
Laszlo has previously posted a solution for toggling groups of hotkeys.

This is much easier with Lexikos' build of AutoHotkey.

Here is my ahk implementation of a vim or viper mode for emacs.
I think its actually better not to use a hidden window, because then i don't remember which group of keys is active now. So I just keep a window stub in the taskbar (unhidden) instead.

Code:
; viper.ahk
;; copyright: Naveen Garg, GPL v2: http://www.gnu.org/licenses/gpl-2.0.html
;; requires: AutoHotkey_L by Lexikos or AutoHotkey.dll by tinku99
!i::     
viperize()
Return


viperize()
{
  Gui 11:Destroy
  Gui 11:Show, Minimize, viperOn ; Hide,
   }

unviperize()
  {
  Gui 11:Destroy
}

#If WinExist("viperOn") and WinActive("ahk_class Emacs")
i::unviperize()
a::send, ^a
m::send, ^{space}  ;; set mark
e::send, ^e
j::
n::
  send, ^n
  return
 
p::
k::
send, ^p
return
,::send, +!,  ;; beginning of page
.::send, +!.  ;; end of page
[::send, !a
]::send, !e 

d::send, ^d  ;; kill letter
^d::send, ^k ;; kill line
!d::send, ^!k  ;; kill next word or sexp
c::send, ^c  ;; next page
w::send, !w  ;; kill region
y::send, ^y
g::send, ^g  ;; cancel command
b::send, !b
r::Reload
q::send, !q  ;; fill paragraph
u::     ;; undo
-::     ;; undo
  send, +^- 
  return


f::
send !f
return

!f:: ;; find file
send, ^x^f
unviperize()
return

o::send, ^xo   ;; other buffer
0::send, ^x0  ;; only other buffer
1::send, ^x1  ;; only this buffer
6::send, ^6   ;; don't know what this does
^b::send, ^x^b ;; switch buffers
!b::  ;; switch to buffer by name
  send, ^xb
  unviperize()
  return
9:: 
  if !defining
  {
    send, ^x( 
    defining = 1
  }
  else
  {
    send, ^x)
    defining =   
  }
 return
^e:: send, ^xe ;; run keyboard macro 

 
/::
  send, ^s ;; search
  unviperize()
  return
^/::
  send, ^r ;; search
  unviperize()
  return
   
s::send, ^x^s  ;; save file
x::  ;; minibuffer command
  send, !x
  unviperize()
  return


!r::Reload

#If



Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: tomoe_uehara, Xx7 and 14 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group