Jim is a JavaScript library that adds a Vim mode to the excellent in-browser editor Ace. Github uses Ace for its editor, so you can use the Jim bookmarklet to Jimmy rig it with Vim-ness.
Jim is no longer maintained. Cloud9 IDE now has a built-in Vim mode, but it doesn't work with standalone Ace AFAIK, so fork away if you'd like to continue this project.
I'm not terribly proud of how the code ended up. Using classes for each of the commands
is a textbook case of OO being over-applied. For an idea of how to implement a Vim-mode
The Right Way, take a look at
Sublime Text 2's Vintage mode. I use it on a
daily basis and it works great. The way commands are "built" with keystrokes and then
executed afterwards with one ViEval
command turns out to be a far superior way to
write a Vim mode.
<script src="ace.js" type="text/javascript"></script>
<script src="jim-ace.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
var editor = ace.edit('editor');
// configure Ace
Jim.aceInit(editor);
});
</script>
- ace.coffee has all the Ace-specific logic for hooking into its keyboard handling, moving the cursor, modifying the document, etc.
- jim.coffee holds all of Jim's state.
- keymap.coffee, well, maps keys.
- modes.coffee defines each of the modes' different key handling behaviors
- Commands are defined in motions.coffee, operators.coffee, and commands.coffee
- Odds and ends get thrown in helpers.coffee
- modes: normal, visual (characterwise and linewise), insert, replace
- operators:
c
,d
,y
,>
, and<
in normal and visual modes (double operators work as linewise commands in normal mode, too) - motions (can be used with
counts and/or operators, and in visual mode)
h
,j
,k
,l
W
,E
,B
,w
,e
,b
0
,^
,$
G
,gg
H
,M
,L
/
,?
,n
,N
,*
,#
f
,F
,t
,T
- other commands
- insert switches:
i
,a
,o
,O
,I
,A
, andC
- commands:
D
,gJ
,J
,p
,P
,r
,s
,x
,X
,u
, and.
- visual mode commands:
gJ
,J
,p
andP
- insert switches:
- default register (operations yank text in the register for pasting)
u
works as it does in Vim (Cmd-z
andCmd-y
still work as they do in Ace)
If you have a feature request create an issue
Take a gander at the issue tracker
git clone git://github.com/misfo/jim.git
cd jim
git submodule update --init
Then just open index.html and you're good to go.
Chrome needs a special command line argument to allow XHRs to files:
google-chrome --allow-file-access-from-files
To keep the development js file built while you develop, you'll need CoffeeScript:
npm install coffee-script
Then build your files in the background:
cake build:ace:watch
Open test/test.html to run the tests
Thanks to all contributors. In other words: thanks sourrust.