Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Modal Vim


  • Please log in to reply
11 replies to this topic
Unambiguous
  • Members
  • 16 posts
  • Last active: Mar 10 2011 06:42 PM
  • Joined: 18 May 2005
This script allows you to make modal VIM commands upon the CAPSLOCK keypress. When CAPS is released, the commands and mode are reset.

I have tried to cover all the basic functions, such as:

Navigation (hjkl),
Repetitions (12w goes to the 12th word to the right)
Yanking and Deleting (whole line, word, and to beginning and end) (d3w cuts three words to the right)

These are all basically just NORMAL mode commands... I don't have any EX commands, or the find and til commands (f and t) (dt3e [delete til 3rd e] could work, but it would take me a bit of time for me to code.)

Since I am using Windows 7, I pin this program (compiled with VIM icon) in my taskbar closest to the start menu, and the entry highlights every time the CAPSLOCK key is pressed.

I am really enjoying VIM-editing in Word, and Firefox edit boxes!

; Modal_Vim.ahk
; Initial Build: Rich Alesi
; Friday, May 29, 2009 

#Persistent
#SingleInstance, Force
SetKeyDelay, -1
CoordMode, Tooltip, Screen
modal =
context =
num =

SetTimer, vim, 100

; Disable CAPSLOCK
$CAPSLOCK::
return


vim:
While GetKeyState("CAPSLOCK", "P")
{
    vimize()
    if modal != 
		Tooltip, %context%: %num%, 60, 10
	else if num !=
		Tooltip, %num%, 60, 10
	else
		Tooltip
	SetTimer, vim, off
}
modal = 
num = 
unvimize()
SetTimer, vim, on
Tooltip
Return

vimize()
{
  Gui 11:Show, Minimize, vimOn ; Hide,
}

unvimize()
{
  Gui 11:Destroy
}

#IFWinExist vimOn

; Multiples
1:: num = %num%1
2:: num = %num%2
3:: num = %num%3
4:: num = %num%4
5:: num = %num%5
6:: num = %num%6
7:: num = %num%7
8:: num = %num%8
9:: num = %num%9
0:: num = %num%0

; ~ toggle case

; Navigation

a::
if modal =
	send, {Home}
else
	Send, +{Home}
	GoSub, Run_Mode
return

e::
if modal =
	send, {end}
else
	Send, +{End}
	GoSub, Run_Mode
return

h::Send, {Left}
j::Send, {Down}
k::Send, {Up}
l::Send, {Right}

w::
if modal =
	send, ^{RIGHT %num%}
else
	Send, +^{RIGHT %num%}
	GoSub, Run_Mode
return

b::
if modal =
	Send, ^{LEFT %num%}
else
	Send, +^{LEFT %num%}
	GoSub, Run_Mode

return


; Searching

/::
  send, ^f ;; search
  unvimize()
  return
^/::
  send, ^h ;; search
  unvimize()
  return 
n::Send {F3}

; Pasting

p::
IfInString, clipboard, `n
{
	Send, {END}{ENTER}^v{DEL}
}
Else
{
	Send, ^v
}
return

+p::
IfInString, clipboard, `n
{
	Send, {Home}^v
}
Else
{
	Send, ^v
}
return

; Indent and Undo
+,::Send, {Home}{HOME}{Del}
+.::Send, {Home}`t
u::Send, ^z
+u:: Send, ^y

; Modal
d::
if modal = 
{
	context = Delete Mode
	modal = x
	;GoSub, Modal_Input
}
else if modal = x
{
	GoSub, GetLineSelection
	GoSub, Run_Mode
}
return

y::
if modal = 
{
	context = Yank Mode
	modal = c
	;GoSub, Modal_Input
}
else if modal = c
{
	GoSub, GetLineSelection
	GoSub, Run_Mode
}
return

r::Reload

#IfWinExist

; ===== SubRoutines =====

GetLineSelection:
	Send, {Home}{Shift Down}{End}{DOWN %num%}{Home}{Shift Up}
Return

Run_Mode:
	Send, ^%modal%
	Send {Left}{RIGHT}
	num =
	modal =
return



tomtutor
  • Guests
  • Last active:
  • Joined: --
Hello there,

Great job on the code

When I try to run your script, either use ahk or convert to exe, I get the following exception
Error at line 21
Line Text: While GetKeyState("CAPSLOCK", "P")
Error:This line does not contain a recognized action.

I am using Windows 7 as well, do you know what the problem might be?

Believer
  • Members
  • 41 posts
  • Last active: Jan 27 2011 11:55 AM
  • Joined: 13 Jun 2008

Hello there,

Great job on the code

When I try to run your script, either use ahk or convert to exe, I get the following exception
Error at line 21
Line Text: While GetKeyState("CAPSLOCK", "P")
Error:This line does not contain a recognized action.

I am using Windows 7 as well, do you know what the problem might be?


You could try changing this:
While GetKeyState("CAPSLOCK", "P")

to this and see if it works:

While GetKeyState("CAPSLOCK", "D")

Not positive, but I think it is looking for either the up ("U") or down ("D") state of caplocks.

See docs: <!-- m -->http://www.autohotke...GetKeyState.htm<!-- m -->

Not tested, probably needs some revising of the actual variables based on the examples in the docs.

AndrejM8
  • Members
  • 39 posts
  • Last active: Jun 09 2011 12:31 AM
  • Joined: 28 Mar 2010
I've modified your script to run on AutoHotkey_L. AHK_L has the really useful #If expression and simplifies the script a lot, check it out:

Ed: Check the next post for any updates of the code.

There is no loop here, you simply switch between vim-mode and insert mode. I've removed some hotkeys (I'm not sure of their purpose, I'm not a VIM expert :p), but I've added some other hotkeys, such as search previous and un-indent (which work in Scite but I don't know if they'll work for other editors).

AndrejM8
  • Members
  • 39 posts
  • Last active: Jun 09 2011 12:31 AM
  • Joined: 28 Mar 2010
12. August 2010
I've added a bunch of more features, and I've also fixed a nasty bug. The bug was in the number handling, basically you could have inputted a number of any size which is a big problem since AHK will blindly execute a command X number of times. I've set the soft limit to 500, but change that if you like. A new feature is the ` key, which enables switching between Shift-mode for some keys, e.g. 12345 will be !@#$%, this is particularly useful when you're using paranthesis a lot. This mode is disabled when vim mode is active. Added forward and backward delete, and a save hotkey.

; Modal_Vim.ahk
; Initial Build: Rich Alesi
; Friday, May 29, 2009
;
; Modified for AHK_L by Andrej Mitrovic
; Version 0.3
; August 12, 2010

;; globals
inputNumber := " "
modal = 0
shift_mode = 0

unvimize()

#SingleInstance force
#MaxHotkeysPerInterval 800000
; #NoTrayIcon
SetWinDelay, 0
CoordMode, Mouse
#Persistent
SetKeyDelay, -1
; CoordMode, Tooltip, Screen

; ^!home::ExitApp

; Close, edit script
; #If (edit_script == 0)
; ^!home::
; WinGetActiveTitle, aTitle
; WinGetClass, class, %aTitle%
; if (class != "IrfanView")
; {
   ; Run, Scite "G:\Documents and Settings\Andrej\Desktop\Ahk Scripts\vim_mode.ahk"
   ; ExitApp
; }
; return
; #If

;;; GUI
notify(text, time = 0)
{
   if (text == "")
   {
      Progress, Off
      return
   }  
   
   Progress, y989 b2 fs10 zh0 W150 WS700, %text%, , , Verdana
   if (time != 0)
   {
      Sleep, %time%
      Progress, Off
   }
   return
}

;;; Number-normalizer, do not allow more than X ammount of digits
normalize(reset_number)
{
   global inputNumber
   if (inputNumber > 500)
   {
      inputNumber := reset_number
   }
}

;;; Mode-Switch key
CAPSLOCK::
{
   if (modal == 0)
   {
      vimize()
      notify("vim mode", 400)
   }
   else
   {
      unvimize()
      notify("insert mode", 400)
   }
   return
}

;;; Mode-Switch and Cleanup Functions
vimize()    ;; Enter Vim mode
{
   global
   modal := true
   resetGUI()
   return
}

unvimize()  ;; Exit Vim mode, do cleanup
{
   global
   modal := false
   resetGUI()
   resetInputNumber()
   return
}

resetInputNumber()
{
   global
   resetGUI()
   inputNumber := " "
}

resetGUI()
{
   Progress, Off
}

SC029::
{
   if (modal == true)
   {
      return    ; Early exit, shift_mode can't be used while in vim mode
   }
   
   if (shift_mode == 0)
   {
      shift_mode = 1
      return
   }
   else
   {
      shift_mode = 0
      return
   }
   return
}

;;; !@#$ shift_mode works only when not in modal mode
#If (shift_mode == true)

$1::!
$2::@
$3::#
$4::$
$5::Send `%
$6::Send {^}
$7::Send {&}
$8::Send {*}
$9::(
$0::)

SC028::Send, {"}

#If


;;; Vim Mode
#If (modal == true)

Esc::   ;; Reset input number and any commands
{
   inputNumber := ""
   Progress, off
   return
}

;;; The following allows appending numbers before a command, 
;;; e.g. 2, 4, w == 24w which can then be used throughout the rest of the commands.
;;; The number is usually reset to 0 by a move/modify command or ESC.
$0::
{
   if (inputNumber < 1)
   {
      return    ;; Putting 0 in first place does not make sense
   }

   inputNumber = %inputNumber%0
   normalize("")
   notify(inputNumber)
   return
}

$1::
{
   inputNumber = %inputNumber%1
   normalize(1)
   notify(inputNumber)
   return
}

$2::
{
   inputNumber = %inputNumber%2
   normalize(2)
   notify(inputNumber)
   return
}

$3::
{
   inputNumber = %inputNumber%3
   normalize(3)
   notify(inputNumber)
   return
}

$4::
{
   inputNumber = %inputNumber%4
   normalize(4)
   notify(inputNumber)
   return
}

$5::
{
   inputNumber = %inputNumber%5
   normalize(5)
   notify(inputNumber)
   return
}

$6::
{
   inputNumber = %inputNumber%6
   normalize(6)
   notify(inputNumber)
   return
}

$7::
{
   inputNumber = %inputNumber%7
   normalize(7)
   notify(inputNumber)
   return
}

$8::
{
   inputNumber = %inputNumber%8
   normalize(8)
   notify(inputNumber)
   return
}

$9::
{
   inputNumber = %inputNumber%9
   normalize(9)
   notify(inputNumber)
   return
}


;;; Navigation
j::
{
   Send, {Left %inputNumber%} 
   resetInputNumber()
   return
}

l::
{
   Send, {Right %inputNumber%} 
   resetInputNumber()
   return
}

i::
{
   Send, {Up %inputNumber%} 
   resetInputNumber()
   return
}

k::
{
   Send, {Down %inputNumber%} 
   resetInputNumber()
   return
}

^i::
{
   Send, {PgUp}
   return
}

^k::
{
   Send, {PgDn}
   return
}

SC027::Send, {Enter}
a::Send, {Home}
e::Send, {End}

w::     ;; Move # words forward
{
   Send, ^{Right %inputNumber%}
   resetInputNumber()
   return
}

b::     ;; Move # words back
{
   Send, ^{Left %inputNumber%}
   resetInputNumber()
   return
}   

[::     ;; Set cursor to previous block
{
   Send, ^[
   return
}

]::     ;; Set cursor to next block
{
   Send, ^]
   return
}

g::     ;; Go to # line number
{
   Send, ^g%inputNumber%{Enter}
   resetInputNumber()
   return
}

;;; Selections
+i::    ;; Select Up
{
   Send, {shift down}{Up %inputNumber%}{shift up}
   resetInputNumber()
   return
}

+k::    ;; Select Down
{
   Send, {shift down}{Down %inputNumber%}{shift up}
   resetInputNumber()
   return
}

+j::    ;; Select Left
{
   Send, {shift down}{Left %inputNumber%}{shift up}
   resetInputNumber()
   return
}

+l::    ;; Select Right
{
   Send, {shift down}{Right %inputNumber%}{shift up}
   resetInputNumber()
   return
}

^+i::    ;; Select Page Up
{
   Send, {shift down}{PgUp}{shift up}
   return
}

^+k::    ;; Select Page Down
{
   Send, {shift down}{PgDn}{shift up}
   return
}

+w::    ;; Select # Next Word
{
   Send, +^{Right %inputNumber%}
   resetInputNumber()
   return
}

+b::    ;; Select # Previous Words
{
   Send, +^{Left %inputNumber%}
   resetInputNumber()
   return
}

+[::    ;; Select to previous block
{
   Send, {ctrl down}{shift down}[{ctrl up}{shift up}
   return
}

+]::    ;; Select to next block
{
   Send, {ctrl down}{shift down}]{ctrl up}{shift up}
   return
}

;;; Search & Replace
/::     ;; Search
{
   Send, ^f             ;; Call the search dialog
   unvimize()           ;; Switch to insert mode
   KeyWait, Enter, D    ;; Enter exits search dialog
   vimize()             ;; Return back to vim mode
   return
}

^/::    ;; Replace
{
   Send, ^h         ;; Call the replace dialog
   unvimize()       ;; Switch to insert mode
   KeyWait, Esc, D  ;; Esc exits replace dialog
   vimize()         ;; Return back to vim mode
   return
}

n::Send {F3}    ;; Search next
+n::Send +{F3}  ;; Search previous


; Editing
$c::     ;; Copy selection
{
   Send ^c
   notify("Selection copied.", 1000)
   return
}

f::    ;; delete # characters
{
   Send, {Backspace %inputNumber%}
   resetInputNumber()
   return
}

d::    ;; backspace delete # characters
{
   Send, {Delete %inputNumber%}
   resetInputNumber()
   return
}

q::     ;; Comment a line or selected lines
{
   Send, ^q
   return
}

u::Send, ^z     ;; Undo
y::Send, ^y     ;; Redo

^u::    ;; Reopen last closed file
{
   Send, {alt down}f{1}{alt up}
   return
}

; :*C:wd::    ;; Delete # words
; {
   ; Send, {CTRL down}DEL %inputNumber%}{CTRL up}
   ; resetInputNumber()
   ; return

; }

;;; Pasting
p::     ;; Paste at new line
IfInString, clipboard, `n
{
   Send, {END}{ENTER}^v{DEL}
}
Else
{
   Send, {END}{ENTER}^v ;^v
}
return

+p::    ;; Paste at beginning of line (does not work for some reason)
IfInString, clipboard, `n
{
   Send, {Home}^v{Enter}
}
Else
{
   Send, ^v
}
return

; Note, this doesnt currently work with multiple selections
;;; Indenting
.::Send, {Home}`t                            ;; Indent  
,::Send, {Home}{Shift Down}{Tab}{Shift Up}   ;; Un-indent

;;; Scite commands
^[::    ;; Select previous tab
{
   Send, {ctrl down}{shift down}{Tab}{shift up}{ctrl up}
   return
}

^]::    ;; Select next tab
{
   Send, ^{Tab}
   return
}

x::     ;; Close tab
{
   Send, ^w
   return
}

s::     ;; Save tab
{
   Send, ^s
   return
}

#If


11. August 2010
I've decided to move away from VIM's default key bindings. I won't be able to replicate many of them anyhow, since many of them depend on features of VIM. So instead I'm trying to make work in Scite easier by binding much of the functionality close to home row, so if anyone wants to use this go ahead.

I've added a bunch more stuff in here, like selection between paragraphs, forward & backward delete, copy&paste, quick close/reopen last closed tab.

; Modal_Vim.ahk
; Initial Build: Rich Alesi
; Friday, May 29, 2009
;
; Modified for AHK_L by Andrej Mitrovic
; August 11, 2010

;; globals
inputNumber := " "
modal = 0

#SingleInstance force
#MaxHotkeysPerInterval 800000
#NoTrayIcon
SetWinDelay, 0
CoordMode, Mouse
#Persistent
SetKeyDelay, -1
; CoordMode, Tooltip, Screen

;;; GUI
notify(text, time = 0)
{
   Progress, y989 b2 fs10 zh0 W150 WS700, %text%, , , Verdana
   if (time != 0)
   {
      Sleep, %time%
      Progress, Off
   }
   return
}

;;; Mode-Switch key
CAPSLOCK::
{
   if (modal == 0)
   {
      vimize()
      notify("vim mode", 400)
   }
   else
   {
      unvimize()
      notify("insert mode", 400)
   }
   return
}

;;; Mode-Switch and Cleanup Functions
vimize()    ;; Enter Vim mode
{
   global
   modal := true
   resetGUI()
   return
}

unvimize()  ;; Exit Vim mode, do cleanup
{
   global
   modal := false
   resetGUI()
   resetInputNumber()
   return
}

resetInputNumber()
{
   global
   resetGUI()
   inputNumber := " "
}

resetGUI()
{
   Progress, Off
}

;;; Vim Commands
#If (modal == true)

Esc::   ;; Exit Vim mode
{
   unvimize()
   return
}

;;; The following allows appending numbers before a command, 
;;; e.g. 2, 4, w == 24w which can then be used throughout the rest of the commands.
;;; The number is usually reset to 0 by a move/modify command or ESC.
$0::
{
   inputNumber = %inputNumber%0
   notify(inputNumber)
   return
}

$1::
{
   inputNumber = %inputNumber%1
   notify(inputNumber)
   return
}

$2::
{
   inputNumber = %inputNumber%2
   notify(inputNumber)
   return
}

$3::
{
   inputNumber = %inputNumber%3
   notify(inputNumber)
   return
}

$4::
{
   inputNumber = %inputNumber%4
   notify(inputNumber)
   return
}

$5::
{
   inputNumber = %inputNumber%5
   notify(inputNumber)
   return
}

$6::
{
   inputNumber = %inputNumber%6
   notify(inputNumber)
   return
}

$7::
{
   inputNumber = %inputNumber%7
   notify(inputNumber)
   return
}

$8::
{
   inputNumber = %inputNumber%8
   notify(inputNumber)
   return
}

$9::
{
   inputNumber = %inputNumber%9
   notify(inputNumber)
   return
}

;;; Navigation
j::
{
   Send, {Left %inputNumber%} 
   resetInputNumber()
   return
}

l::
{
   Send, {Right %inputNumber%} 
   resetInputNumber()
   return
}

i::
{
   Send, {Up %inputNumber%} 
   resetInputNumber()
   return
}

k::
{
   Send, {Down %inputNumber%} 
   resetInputNumber()
   return
}

^i::
{
   Send, {PgUp}
   return
}

^k::
{
   Send, {PgDn}
   return
}

a::Send, {Home}
e::Send, {End}

w::     ;; Move # words forward
{
   Send, ^{Right %inputNumber%}
   resetInputNumber()
   return
}

b::     ;; Move # words back
{
   Send, ^{Left %inputNumber%}
   resetInputNumber()
   return
}   

[::     ;; Set cursor to previous block
{
   Send, ^[
   return
}

]::     ;; Set cursor to next block
{
   Send, ^]
   return
}

;;; Selections
+i::    ;; Select Up
{
   Send, {shift down}{Up %inputNumber%}{shift up}
   resetInputNumber()
   return
}

+k::    ;; Select Down
{
   Send, {shift down}{Down %inputNumber%}{shift up}
   resetInputNumber()
   return
}

+j::    ;; Select Left
{
   Send, {shift down}{Left %inputNumber%}{shift up}
   resetInputNumber()
   return
}

+l::    ;; Select Right
{
   Send, {shift down}{Right %inputNumber%}{shift up}
   resetInputNumber()
   return
}

^+i::    ;; Select Page Up
{
   Send, {shift down}{PgUp}{shift up}
   return
}

^+k::    ;; Select Page Down
{
   Send, {shift down}{PgDn}{shift up}
   return
}

+w::    ;; Select # Next Word
{
   Send, +^{Right %inputNumber%}
   resetInputNumber()
   return
}

+b::    ;; Select # Previous Words
{
   Send, +^{Left %inputNumber%}
   resetInputNumber()
   return
}

+[::    ;; Select to previous block
{
   Send, {ctrl down}{shift down}[{ctrl up}{shift up}
   return
}

+]::    ;; Select to next block
{
   Send, {ctrl down}{shift down}]{ctrl up}{shift up}
   return
}

;;; Search & Replace
/::     ;; Search
{
   Send, ^f             ;; Call the search dialog
   unvimize()           ;; Switch to insert mode
   KeyWait, Enter, D    ;; Enter exits search dialog
   vimize()             ;; Return back to vim mode
   return
}

^/::    ;; Replace
{
   Send, ^h         ;; Call the replace dialog
   unvimize()       ;; Switch to insert mode
   KeyWait, Esc, D  ;; Esc exits replace dialog
   vimize()         ;; Return back to vim mode
   return
}

n::Send {F3}    ;; Search next
+n::Send +{F3}  ;; Search previous


; Editing
$c::     ;; Copy selection
{
   Send ^c
   notify("Selection copied.", 1000)
   return
}

d::     ;; Forward delete # characters
{
   Send, {DEL %inputNumber%}
   resetInputNumber()
   return
}

+d::    ;; Backward delete # characters
{
   Send, {Backspace %inputNumber%}
   resetInputNumber()
   return
}

q::     ;; Comment a line or selected lines
{
   Send, ^q
   return
}

u::Send, ^z     ;; Undo
y::Send, ^y     ;; Redo

^u::    ;; Reopen last closed tab
{
   Send, {alt down}f{1}{alt up}
   return
}

; :*C:wd::    ;; Delete # words
; {
   ; Send, {CTRL down}DEL %inputNumber%}{CTRL up}
   ; resetInputNumber()
   ; return

; }

;;; Pasting
p::     ;; Paste at new line
IfInString, clipboard, `n
{
   Send, {END}{ENTER}^v{DEL}
}
Else
{
   Send, {END}{ENTER}^v ;^v
}
return

+p::    ;; Paste at beginning of line (does not work for some reason)
IfInString, clipboard, `n
{
   Send, {Home}^v{Enter}
}
Else
{
   Send, ^v
}
return

;;; Indenting
+.::Send, {Home}`t                      ;; Indent  
+,::Send, {Home}{Shift Down}{Tab}{Shift Up}   ;; Un-indent

;;; Miscellanous Scite commands
^[::    ;; Select previous file
{
   Send, {ctrl down}{shift down}{Tab}{shift up}{ctrl up}
   return
}

^]::    ;; Select next file
{
   Send, ^{Tab}
   return
}

x::     ;; Close tab
{
   Send, ^w
   return
}

#If


10. August 2010
I will be posting updates here, but I might fire up a repository later.

Updates:
* A non-modal pop-up will appear in the bottom when switching modes. Currently there's VIM mode and "Insert" mode.
* Can use numbers before commands, so you can do "2, 5, w", and that will move you 25 words forward. It will automatically reset itself to zero, just like in VIM. Edit: This was in the first script but I managed to remove it by accident. Sorry.


; Modal_Vim.ahk
; Initial Build: Rich Alesi
; Friday, May 29, 2009
;
; Modified for AHK_L by Andrej Mitrovic
; August 10, 2010

#Persistent
#SingleInstance, Force
SetKeyDelay, -1
CoordMode, Tooltip, Screen

;; globals
inputNumber := " "
modal := false

;;; GUI
notify(text, time = 2000)
{
   ; Progress, y980 b2 fs10 zh0 WS800, %text%, , , Verdana
   Progress, y989 b2 fs10 zh0 W150 WS700, %text%, , , Verdana
   Sleep, %time%
   Progress, Off
   return
}

;;; Mode-Switch key
CAPSLOCK::
if (modal == false)
{
   vimize()
}
else
{
   unvimize()
}
return

;;; Mode-Switch and Cleanup Functions
vimize()    ;; Enter Vim mode
{
   global
   modal := true
   notify("vim mode", 600)
   return
}

unvimize()  ;; Exit Vim mode, do cleanup
{
   global
   modal := false
   notify("insert mode", 600)
   resetInputNumber()
   return
}

resetInputNumber()
{
   global
   inputNumber := " "
}


;;; Modal Commands
#If (modal == true)


;;; The following allows appending numbers before a command, 
;;; e.g. 2, 4, w == 24w which can then be used throughout the rest of the commands.
;;; The number is usually reset to 0 by a move/modify command or ESC.

Esc::
{
   unvimize()
   return
}

0::
{
   inputNumber = %inputNumber%0
   return
}

1::
{
   inputNumber = %inputNumber%1
   return
}

2::
{
   inputNumber = %inputNumber%2
   return
}

3::
{
   inputNumber = %inputNumber%3
   return
}

4::
{
   inputNumber = %inputNumber%4
   return
}

5::
{
   inputNumber = %inputNumber%5
   return
}

6::
{
   inputNumber = %inputNumber%6
   return
}

7::
{
   inputNumber = %inputNumber%7
   return
}

8::
{
   inputNumber = %inputNumber%8
   return
}

9::
{
   inputNumber = %inputNumber%9
   return
}



;;; Navigation
j::
{
   Send, {Left %inputNumber%} 
   resetInputNumber()
   return
}

l::
{
   Send, {Right %inputNumber%} 
   resetInputNumber()
   return
}

k::
{
   Send, {Down %inputNumber%} 
   resetInputNumber()
   return
}

i::
{
   Send, {Up %inputNumber%} 
   resetInputNumber()
   return
}

a::Send, {Home}
e::Send, {End}
w::
{
   Send, ^{Right %inputNumber%}
   resetInputNumber()
   return
}

b::
{
   Send, ^{Left %inputNumber%}
   resetInputNumber()
   return
}

;;; Searching
/::Send, ^f     ;; Search
n::Send {F3}    ;; Search next
+n::Send +{F3}  ;; Search previous
^/::Send, ^h    ;; Replace

;;; Pasting
p::     ;; Paste at new line
IfInString, clipboard, `n
{
   Send, {END}{ENTER}^v{DEL}
}
Else
{
   Send, ^v
}
return

+p::    ;; Paste at beginning of line (does not work for some reason)
IfInString, clipboard, `n
{
   Send, {Home}^v
}
Else
{
   Send, ^v
}
return

;;; Indent and Undo
+.::Send, {Home}`t                      ;; Indent  
+,::Send, {Shift Down}{Tab}{Shift Up}   ;; Un-indent
u::Send, ^z     ;; Undo
+u::Send, ^y    ;; Redo

#If


Unambiguous
  • Members
  • 16 posts
  • Last active: Mar 10 2011 06:42 PM
  • Joined: 18 May 2005
Thanks for making the script your own. I am currently going through it and gonna try to see how I can merge a few of your ideas to get this working a bit better.

Nxqd3051990
  • Members
  • 15 posts
  • Last active: Jun 21 2011 11:36 PM
  • Joined: 25 Jun 2007

Thanks for making the script your own. I am currently going through it and gonna try to see how I can merge a few of your ideas to get this working a bit better.

I'm looking forward to see your script. I will work on one after this final semester exercises :)

Chicken Pie 4 Tea
  • Members
  • 379 posts
  • Last active: Dec 12 2014 06:46 PM
  • Joined: 18 Aug 2009
It would be better if these two different versions were in two separate threads now as one is for ahk_L and its a bit confusing.
"Choose your parents wisely"

guest3456
  • Members
  • 1704 posts
  • Last active: Nov 19 2015 11:58 AM
  • Joined: 10 Mar 2011

It would be better if these two different versions were in two separate threads now as one is for ahk_L and its a bit confusing.


i agree :)

heres a link where a guy creates a script to open up gvim to edit and then copies the output back into out look

<!-- m -->http://jamesoff.net/... ... n-outlook/<!-- m -->

achal
  • Members
  • 1 posts
  • Last active: Apr 28 2012 11:53 PM
  • Joined: 28 Apr 2012
That script is extremely useful, thanks! I made some updates, but I don't know if you'll want to especially incorporate them. Some of them make it more Vim like, others are just personal choices. If you'd like to take a look at it: <!-- m -->https://github.com/a...dows-Navigation<!-- m -->

Thanks again!

guest3456
  • Members
  • 1704 posts
  • Last active: Nov 19 2015 11:58 AM
  • Joined: 10 Mar 2011
another github branch of this is here:
<!-- m -->https://github.com/M...utohotkey_viper<!-- m -->

  • Guests
  • Last active:
  • Joined: --
Any idea why this script might be using insanely high CPU, btw? I'm on Windows 7, and dwm's power usage shoots to ~25% when using the script.