Comments (9)
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.
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.
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.
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.
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.
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.
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.
@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.
Closing though since the issue is solved
from brace.
Related Issues (20)
- ace.edit can't find div #javascript-editor inside Angular Material elements
- Lua mode doesn't support the Lua 5.3 floor-division operator '//' HOT 1
- Typo in searchbox.js
- Upgrade ace editor version to latest HOT 7
- Add support to Firefox nunjucks
- Wrong cursur width when typing Asian Characters under Vim Mode HOT 1
- Support for flatbuffers mode
- About AutoCompletion
- Mismatched / incorrect types
- setValue method is emitting the change event twice HOT 2
- Could brace format js code?
- The getname() method cannot get the result of the error prompt in time HOT 1
- Get errors list or invalid state
- How to get Range from Brace and TypeScript? HOT 1
- Hi,how to show line number? HOT 1
- Accessibility: Add role=log attribute to autocomplete popup. #1777
- Question/Accessibility: what is the keyboard combo to get out of of the focus trap?
- Keyboard trap is observed between tool bar section and code block under "Module Twin" tab. HOT 3
- seems not working for chrome mv3 extensions.
- editor: assigning value during initialization of editor
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from brace.