On command-line mode, Delete
key erases next character, but if cursor is at end of line, it acts as Backspace
, erasing previous character. Can I disabled that?
1 Answer
Try this:
:cnoremap <expr> <del> strlen(getcmdline()) == getcmdpos() - 1 ? '' : "\<del>"
This binds the delete key on the :-command line to running an expression and executing the keystrokes the expression returns. In this case I'm using a ternary operator to return nothing if the length is the same as the cursor position, and returning the delete key otherwise.