1

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 1

2

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.