Figured it out. Go to 
``$:/plugins/tiddlywiki/codemirror/edit-codemirror.js`` and add desired 
function calls as follows

```
/*\
title: $:/plugins/tiddlywiki/codemirror/edit-codemirror.js
type: application/javascript
module-type: widget

Edit-codemirror widget

\*/
(function(){

/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";

var editTextWidgetFactory = 
require("$:/core/modules/editor/factory.js").editTextWidgetFactory,
CodeMirrorEngine = 
require("$:/plugins/tiddlywiki/codemirror/engine.js").CodeMirrorEngine;

exports["edit-codemirror"] = 
editTextWidgetFactory(CodeMirrorEngine,CodeMirrorEngine);

/* place  codemirror function calls here */
CodeMirror.Vim.map('kj', '<Esc>', 'insert');
})();
```


On Thursday, January 2, 2020 at 10:35:48 AM UTC-5, Matthew Phelps wrote:
>
> I am trying to remap a keybind for the <esc> sequence within CodeMirror's 
> vim editor in TW5. The vim editor does support the use of the ex command 
> :imap kj <Esc>
> however this is not a global approach. As outlined in 
> https://github.com/codemirror/CodeMirror/issues/2840, it would seem I 
> need to call the js function
> CodeMirror.Vim.map('kj', '<Esc>', 'insert')
>
> I  have tried including the above call within 
> *$:/plugins/tiddlywiki/codemirror/keymap/vim.js 
> *but to no avail. However, I may not be implementing the call correctly. 
>
> *Is there a method to run the necessary script whenever vim.js is called?*
>
> For reference, here is the defined vim.js 
> https://codemirror.net/keymap/vim.js. I was trying to include  
> CodeMirror.Vim.map('kj', '<Esc>', 'insert')
> after 
> CodeMirror.Vim = Vim();
> near the very bottom of vim.js.
>
> Thanks for any help!
>

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/f94297f8-aaaa-4537-a43e-c3069530faa7%40googlegroups.com.

Reply via email to