Hi there!
I am making Online PHP Debugger using Vim mod (keymap/vim.js).
But I want it to start with insert mode instead of command mode by default.
Could you please tell me how to do that?
Thank you.
Hi, I came across the same question and didn’t find a way to configure the desired behavior. However a little patch just does the job. Add the following line at the end of the enterVimMode
function in vim.js
:
actions['enterInsertMode'](cm, {insertAt: 'inplace'}, cm.state.vim);
1 Like
Thanks for posting that @jecb
Looks like that fix still works for me too…
I tried many iterations of things like:
var MyEditor = CodeMirror.fromTextArea(targetTextArea, {
vimMode: true,
keyMap: "vim-insert",
});
CodeMirror.signal(MyEditor, "vim-mode-change", {mode: "insert"});
MyEditor.setOption('keyMap', 'vim-insert')
and
But I couldn’t get an of these to work…
I followed @jecb instructions and edited vim.js, and it works great… insert mode by default, but back to normal vim mode when you hit escape:
function enterVimMode(cm) {
cm.setOption('disableInput', true);
cm.setOption('showCursorWhenSelecting', false);
CodeMirror.signal(cm, "vim-mode-change", {mode: "normal"});
cm.on('cursorActivity', onCursorActivity);
maybeInitVimState(cm);
CodeMirror.on(cm.getInputField(), 'paste', getOnPasteFn(cm));
# begin added line...
actions.enterInsertMode(cm, {insertAt: 'inplace'}, cm.state.vim);
# end added line
}
Also found this github issue about changing to vim mode with “setOption” but doesn’t seem to work for setting the vim mode…