AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

VIM

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
dsrbecky



Joined: 28 Nov 2004
Posts: 1

PostPosted: Sun Nov 28, 2004 2:45 pm    Post subject: VIM Reply with quote

Press CapsLock or ESC to activate command mode and ‘I’ to return to typing mode
Alternatively press and hold CapsLock, use commands and release CapsLock to return to typing mode

Code:
;file vim.ahk
;this file must be run as sepparate script (use "Run, vim.ahk")
#NoTrayIcon
SetCapsLockState, AlwaysOff
Suspend, On

;Command mode
ESC::
CapsLock::
   Suspend, Off
   commandkey = %A_ThisHotkey%
   CoordMode, ToolTip, Screen
   ToolTip, Command mode active, 0, 0
   Keywait, %commandkey%
   if A_ThisHotkey <> %commandkey%
   {
      Gosub Typingmode
   }
return

TypingMode:
   ToolTip
   Suspend, On
return

I::Gosub TypingMode
H::Send, {Left}
J::Send, {Down}
K::Send, {Up}
L::Send, {Right}
X::Send, {Delete}
A::Send, {End}i
O::Send, {End}{Enter}i
D::Send, {End}{Shift down}{Home}{Shift up}{Delete}
U::Send, ^z
^R::Send, ^y
W::Send, ^{Right}
B::Send, ^{Left}
+4::Send, {End}
0::Send, {Home}
+6::Send, {Home}
+5::Send, ^b
^F::Send, {PgDn}
^B::Send, {PgUp}
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10467

PostPosted: Sun Nov 28, 2004 7:09 pm    Post subject: Reply with quote

Nice script. I know it will be of interest to those used to navigating with those keys on Unix and such. Thanks for posting it.
Back to top
View user's profile Send private message Send e-mail
savage



Joined: 02 Jul 2004
Posts: 206

PostPosted: Thu Dec 09, 2004 10:27 pm    Post subject: Reply with quote

Hey! I was going to write something similar! I keep hitting :w to save in visual studio Razz I keep meaning to make that a hotstring to send ^s but I'm a lazy bum.

That would be a useful addition to your script btw, using Input or hotstrings or somesuch to do basic : commands. Maybe :w :q :e and others. / could bring up find window and fill in what you typed after.
Back to top
View user's profile Send private message AIM Address
savage



Joined: 02 Jul 2004
Posts: 206

PostPosted: Thu Dec 16, 2004 9:11 pm    Post subject: Reply with quote

Here's my version. I couldn't get dsrbecky's version to work at all, I guess because it starts suspended, so the key to unsuspend it is suspended....

Mine includes some : functions, and doesn't activate if you're in a gvim window.

Code:
;
; AutoHotkey Version: 1.x
; Language:       English
; Platform:       Win9x/NT
; Author:         savage
;
; Script Function:
;   VIM-mode for windows. Standard movement and basic : commands.
;

;---AUTORUN SECTION
#NoTrayIcon
#UseHook on
SetCapsLockState, AlwaysOff
SetTitleMatchMode, 2
Running = false

;---HOTKEY SECTION
;Command Mode
~ESC::
   IfWinActive, GVIM
     {
           return
       }
   If running = true
   {
      GoSub, TypingMode
   }
       else
       {
           Running = true
           CoordMode, ToolTip, Screen
           ToolTip, Command mode active, 0, 0       
       }
return

TypingMode:
   ToolTip
   Running = false
return

I::
   If running = true
   {
             Gosub TypingMode     
       }
   else
   {
      send, i
   }
return

H::
   If running = true
       {
             Send, {left}
       }
       else
       {
               Send, h
       }
return

J::
   If running = true
       {
             Send, {down}
       }
       else
       {
               Send, j
       }
return

K::
   If running = true
       {
             Send, {up}
       }
       else
       {
               Send, k
       }
return

L::
   If running = true
       {
             Send, {right}
       }
       else
       {
               Send, l
       }
return

X::
   If running = true
       {
           Send, {Delete}
       }
       else
       {
           Send, x
       }
return

A::
   If running = true
       {
             Send, {end}
             GoSub, TypingMode
       }
       else
       {
               Send, a
       }
return

O::
   If running = true
       {
             Send, {End}{Enter}
             GoSub, TypingMode
       }
       else
       {
               Send, o
       }
return

D::
   If running = true
       {
             Send, {end}{Shift down}{home}{Shift up}^x
       }
       else
       {
               Send, d
       }
return

P::
   If running = true
       {
             Send, ^v
       }
       else
       {
               Send, p
       }
return

Y::
   If running = true
       {
             Send, ^c
       }
       else
       {
               Send, y
       }
return

U::
   If running = true
       {
             Send, ^z
       }
       else
       {
               Send, u
       }
return

^R::
   If running = true
       {
             Send, ^y
       }
       else
       {
               Send, r
       }
return

W::
   If running = true
       {
             Send, ^{Right}
       }
       else
       {
               Send, w
       }
return

B::
   If running = true
       {
             Send, ^{Left}
       }
       else
       {
               Send, b
       }
return

+4::
   If running = true
       {
             Send, {End}
       }
       else
       {
               Send, +4
       }
return

0::
   If running = true
       {
             Send, {Home}
       }
       else
       {
               Send, 0
       }
return

+6::
   If running = true
       {
             Send, {Home}
       }
       else
       {
           Send, +6
       }
return

+5::
   If running = true
       {
             Send, ^b
       }
       else
       {
           Send, +5
       }
return

^F::
   If running = true
       {
             Send, {PgDn}
       }
       else
       {
               Send, ^f
       }
return

^B::
   If running = true
       {
             Send, {PgUp}
       }
       else
       {
               Send, ^b
       }
return

+`;::
   if running = true
   {
      running = false
          Input, UserInput, L3, {enter}
          if UserInput = w
      {
         Send, ^s
      }
      else if UserInput = wq
      {
         Send, ^s
         WinClose, A
      }
      else if UserInput = q
      {
         WinClose, A
      }
      else if UserInput = e
      {
          Send, ^o
      }
      else if UserInput = bn
      {
         Send, !{Tab}
      }
      else if UserInput = bp
      {
         Send, +!{Tab}
      }
      running = true
   }
   else
   {
      Send, +`;
   }
return

^!r::Reload
^!x::ExitApp


It's a lot longer, but it can be integrated into antheor script, unlike the other one. Enjoy!
Back to top
View user's profile Send private message AIM Address
oversky



Joined: 03 Nov 2005
Posts: 6

PostPosted: Thu Nov 03, 2005 2:29 am    Post subject: Reply with quote

Hi,
Savage, this script is what I am looking after viming. Thanks.
I found that I could not type captal letters with your script. Do you have a newer version?
Back to top
View user's profile Send private message
savage



Joined: 02 Jul 2004
Posts: 206

PostPosted: Thu Nov 03, 2005 3:12 pm    Post subject: Reply with quote

No, I haven't looked at it in a long time. I don't recall ever having a problem typing capitals though. I think it's possible to rewrite it in a much more compact fashion now so maybe I'll have a go at a new version.
_________________
<enormous animated gif>
Back to top
View user's profile Send private message AIM Address
roshanpv
Guest





PostPosted: Mon Oct 23, 2006 1:46 pm    Post subject: VIM KEY BINDINGS!!! HELP NEEDED Reply with quote

Hai Guys
I have a better idea but i don't know autohotkey scripting i just downloaded it today a few minutes back
I read that autohotkey let's you define custom modifiers.
Why not create custom modifier to emulate the vim keys
for example

f & h to be left
f & J to be down
f & k to be up
f & l to be right

I will ding into the documentation today and try to figure out if it can be implemented

It's very important for me to emulate vim keys everywhere in windows i am so used to it...........
But if somebody else can post the script it would be of great help
Back to top
Guest






PostPosted: Thu Jul 26, 2007 9:29 am    Post subject: Reply with quote

savage wrote:
Here's my version. I couldn't get dsrbecky's version to work at all, I guess because it starts suspended, so the key to unsuspend it is suspended....

Mine includes some : functions, and doesn't activate if you're in a gvim window.

[...]

It's a lot longer, but it can be integrated into antheor script, unlike the other one. Enjoy!


The functions in this is incomplete. I can't use shift to highlight and using H J K L to highlight the Characters.

Anyone knows how i can do this.

I have tried something like this. but it doesn't work
LShift::
send, {shift down}
keyWait LShift
send, {shift up}
return
Back to top
isd
Guest





PostPosted: Thu Oct 11, 2007 4:36 am    Post subject: Problem with vimperator Reply with quote

I use vimperator for firefox and since I have installed this script (the savage version) vimperator doesn't capture any keystroke anymore...
I tried to deactivate the script the way it deactivates when running Gvim but it didn't work....
help
Back to top
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group