Giter VIP home page Giter VIP logo

Comments (9)

thlorenz avatar thlorenz commented on June 9, 2024

please look at this example and it'll show you how you need to require things directly.
Just using ace.require won't work.

from brace.

tylerlong avatar tylerlong commented on June 9, 2024

I did look at that. And my last sentence said require('brace/keybinding/vim') seemed like an empty object.

I just cannot obj.CodeMirror.Vim. Could you please reopen this issue? Or could you please do me a favor to post sample code for the following:

const Vim = ace.require('ace/keyboard/vim').CodeMirror.Vim
Vim.defineEx('write', 'w', (cm, input) => {
  console.log('write')
})

?

from brace.

thlorenz avatar thlorenz commented on June 9, 2024

Just do it like in the example, it will be an empty object as the require just ensures that the binding file will be part of the bundle so that you can use it as is shown here.

Just use the Vim binding like in the example. Have you tried running the example and does that work for you? WRT code mirror API I don't know. Does that exact code work with ace itself even?

from brace.

tylerlong avatar tylerlong commented on June 9, 2024

My question is not how to enable Vim mode. Your example already shows how to do that and I did read your example.

I want to customize Vim commands such as :w to save the file. The code does work with ACE. http://stackoverflow.com/a/28084432/862862 I tried it myself and it does work. Problem is I don't know how to write similar code with brace.

Here is a slightly different version written by myself (with ACE): https://github.com/tylingsoft/markdown-plus/blob/master/src/editor.js#L69-L82

from brace.

thlorenz avatar thlorenz commented on June 9, 2024

ah ok now I understand your problem, sorry for being slow.

I have no idea why this isn't working with brace as it is with ACE. It should.
Maybe we are missing some modules we need to pull in? Or are we still based on a version of ACE that doesn't have that feature?
We'd need to find out what part of ACE enables customizing Vim commands and make sure we pull those files in as well.

I personally have no bandwidth to look into that, but I'm reopening the issue. Hopefully someone can have a look, or if you have time to look into this, I'd greatly appreciate a PR :)

from brace.

ashervb avatar ashervb commented on June 9, 2024

Ran into the same problem myself, the solution is to use ace.acequire rather than ace.require:

    const ace = require("brace")
    const Vim = ace.acequire('ace/keyboard/vim').CodeMirror.Vim

    Vim.defineEx('write', 'w', (cm, input) => {
      console.log('write')
    })

from brace.

matthijsgroen avatar matthijsgroen commented on June 9, 2024

This works for me:

const ace = require("brace");
require('brace/keybinding/vim')

const editor = ace.edit("editor");

ace.config.loadModule("ace/keyboard/vim", module => {
  const VimApi = module.CodeMirror.Vim;
  VimApi.defineEx("write", "w", (cm, input) => {
    console.log("write");
  });
});
editor.setKeyboardHandler("ace/keyboard/vim");

from brace.

thlorenz avatar thlorenz commented on June 9, 2024

@matthijsgroen could you please create a wiki page here so we can collect these tricks and link to them from the readme? Just do Add New Page.
Thanks.

from brace.

thlorenz avatar thlorenz commented on June 9, 2024

Closing though since the issue is solved

from brace.

Related Issues (20)

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.