I am using Codemirror. My code doesn't use ES6 modules. I would like to know
how to get at the Vim object? On the Codemirror Vim readme, we see:
import {Vim, getCM} from "@replit/codemirror-vim"
let cm = getCM(view)
// use cm to access the old cm5 api
Vim.exitInsertMode(cm)
Vim.handleKey(cm, "<Esc>")
Vim.map("jj", "<Esc>", "insert"); // in insert mode
Vim.map("Y", "y$"); // in normal mode
(I am especially interested in .map). However this gives an error if used in a <script type="module">...</script>
in an HTML file due to the @replit bit. How do I get at the Vim object within a <script> in HTML?
I am getting Codemirror via the following
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.62.0/codemirror.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.62.0/mode/markdown/markdown.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.62.0/keymap/vim.min.js"></script>
Embarrassingly I found the answer shortly after posting the question.
We can simply do, for example,
So the Vim object appears inside the CodeMirror object.