My goal is to change the behaviour such that all vim commands that delete an entire line or several lines call a specific function instead.
This is my most recent try:
import * as ace from 'ace-builds';
this.aceEditor = ace.edit(this.editor.nativeElement);
ace.require('ace/keybindings/vim');
this.aceEditor.setKeyboardHandler('ace/keyboard/vim');
ace.config.loadModule('ace/keyboard/vim', () => {
var VimApi = ace.require('ace/keyboard/vim').CodeMirror.Vim;
VimApi.defineEx('delete', 'd', this.deleteCurrentLineIfSolved.bind(this));
});
I have also tried using the mapCommand(), unmap() and map() functions.
The command in question appears to be defined starting on line 2352 of this repository: https://github.com/replit/codemirror-vim/blob/master/src/vim.js But I do not fully understand its inner workings.
Changing the 'delete' 'd' key does not appear to do anything. I am unsure how to specifically target specific hotkeys such as 'd' 'd' for deleting lines.
Any help would be much appreciated.
You can use VimApi.defineOperator('delete', fn)
to change the delete function. But depending on what exactly you want to change there may be a better way too.