Coder Social home page Coder Social logo

jim's Introduction

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.

Project status

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.

Try it out

misfo.github.com/jim

Embed Jim with Ace in your app

<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>

Annotated source

What works so far

  • 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, and C
    • commands: D, gJ, J, p, P, r, s, x, X, u, and .
    • visual mode commands: gJ, J, p and P
  • default register (operations yank text in the register for pasting)
  • u works as it does in Vim (Cmd-z and Cmd-y still work as they do in Ace)

If you have a feature request create an issue

Known issues

Take a gander at the issue tracker

Hack

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!

Thanks to all contributors. In other words: thanks sourrust.

jim's People

Contributors

misfo avatar sourrust avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

jim's Issues

more common motions

I'd like to see f and F as well as L, M, and H. And since you just implemented /, I think it would be appropriate to complement it with ?.

Navigation/selection for international characters (e.g. Icelandic)

I'm a pretty heavy user of Ace with vim mode in RStudio, which looks like it is based on jim. I like it very much, but I´m running into some issues with international characters. They seem to be treated as word boundaries by the vim commands. In Ace itself, they are handled correctly, which is why I am reporting this here.

Reproducible example:

Enter the following text in a vim-enabled Ace editor such as http://misfo.github.io/jim/

abcædef another word
abcþdef another word
abcödef another word
  1. Double-click on the first word in each line to observe that core Ace treats international characters (here æ, þ, ö) as part of the first word, in that the whole word is selected.
  2. Go to the start of any of the lines and type vw, cw, dw, w, or b to observe that these commands incorrectly treat the international characters as word boundaries.

`w` and `W` special EOL behavior in operations

w and W motions that would normally move to the first non-blank of the next line (e.g. pressing 2w on the second to last word in a line), only operate to the end of the line (i.e. d2w on the second to the last word of a line just deletes to the end of the line). This special case needs to be implemented.

Here's the failing test case:

test "c won't join lines when it has a non-linewise motion", ->

Jim's state should jive with mouse clicks/selections

Jim is not taking into account any mouse events that may have happened between the current keystroke and the last. So it will do unexpected things if the user selects some text, for example, and then tries to do a visual mode command.

Either the mouse events need to be hooked into or some sanity checks need to be made at the beginning of each key event. The latter is probably a better option so the plugin will stay as close to a keybinding as possible.

repeating new line inserts doesn't create a new line

osomething<esc>. and Osomething<esc>. don't create new lines for the repeat. "something" is inserted whereever the cursor is on the current line in both cases. Unfortunately this can't be reproduced in the tests

text-objects motions (i_, a_)

With _ being one of the following values (in usefulness order): ", ', t, (, ), [. ], {, }, <, >, w. I'd love to see these. Proper behaviour when combined with counts is unnecessary for me, but would be impressive.

If you're not familiar with these motions, :h text-objects

edit: remember that these are not just motions in visual mode, but motions for c, d, y, etc.

backspace in replace mode

This may be a little difficult, but it's one of the more important features of replace mode. I'd either remove replace mode or implement the backspace functionality.

`o` in visual mode

This is one of those features that you're really glad exists when you need it. I haven't seen any other editor with a similar feature either, which is a shame.

The CoffeeScript is too beautiful

I have a major issue with how beautiful the CoffeeScript is, especially in the Ace adapter section of the code. Please fix this.

THX.

improve repeating of inserts with <Backspace> pressed

If you insert some text, hit <Backspace> a few times, and then insert some more text then only the text after the <Backspaces> will be inserted in the repeat.

The logic in lastInsert method needs to handle backspaces just like Vim.

dot command

Should work for basic commands, operations, inserts, linewise visual commands, single- and multi-line characterwise visual commands.

Support bookmarks

I'm used to doing things with m + <letter>, would be nice to see that in Jim.

`;` and `,` motions

These are kinda useful and should be easy to implement since f, t, F, and T already work

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.