Vim-Like Keybindings with Apple Script

I’ve been loving using Bike, even without my dream Vim-like keybindings. I particularly like that it’s extensible with Apple Scripts. I’ve been messing around with it and haven’t gotten very far (this is literally the first I’ve ever messed with Apple scripts and it’s all a bit over my head for now). However, when I was puttering around I noticed that under ‘Bike Suite’ in ‘Bike.sdef’ there is an entry for ‘edit mode’ with options for ‘text mode’ and ‘outline mode’. I’m wondering if anyone knows if that is an attribute that a running script can use as a trigger or condition or if it is just a command? I was thinking if I can use it to trigger stuff I might be able to write a script that functions something like “if bike is in outline mode then hjkl are remapped as left/down/up/right”. It wouldn’t be perfect but that would be 90% of getting Vim-like behavior. I’m not looking for anyone to do the work for me but I’d appreciate someone knowledgeable letting me know if it’s even possible. Thanks in advance!

Yes you can read/write edit mode like this:

tell application "Bike"
	tell front document
		if edit mode = text mode then
			set edit mode to outline mode
		else
			set edit mode to text mode
		end if
	end tell
end tell

I’ve been implementing AppleScript support for nearly 20 years (eek) and it’s still a bit over my head too. It’s not that it’s a bad design I think, more that it’s different than most programming languages and I only ever use it just long enough to forget how it all works each time.

Generally when I need to do something with it I go (cross my finders) and find a similar example from this page and then modify it:

Awesome! Now I need to see if I can figure how to do the rest of it. :slight_smile:

Man this does not seem simple to implement… I know you are working on bike 2.0 at the moment so I don’t really want to put too much effort into this and it seems like at a minimum I would need to install other software.

On that note if you’re looking for inspiration on how to implement keybindings to make them vim-like you should check out this project. It’s old and abandoned but it is an amazing implementation.

Ah, sorry I never really read closely what you were trying to do… I just latched onto if bike is in outline mode then … sorry about that…

Yeah… implementing VIM keybindings in ApplesScript probably isn’t the right technology. AppleScript is more of an automation technology and also for connecting apps together.

I do expect “eventually” that I will provide a deeper level javascript based plugin/scripting layer. That will be the place for this kind of extension, but when? I don’t know.

1 Like

Have you looked at alternative methods for getting Vim mode on macOS? I haven’t tried, but seems there are a number of possibilities here:

I had no idea this stuff existed. I know what I’m doing for my friday night!

1 Like