Does anyone know how to map the backspace and delete keys in Vimscript?
Once in insert mode, you can type in your text. Press ENTER at the end of each line. Use Backspace to delete to the left of the cursor. If you need to move the cursor to another line, or make a change, or pretty much anything else, you need to press ESC to get back to Command mode first.
From Normal mode, you can type :
then Press Ctrl+k followed by any key, and vim will tell you how to reference it. For example, from normal mode typing :
then pressing Ctrl+k and pressing Backspace results in:
:<BS>
Then you can remap like normal:
:map <BS> :echo 'You pressed backspace!'<CR>
:map <Del> :echo 'You pressed Delete!'<CR>
Obviously you'll want to do something more useful than that, so change the part from :echo
onward. Here is a helpful tutorial to get started if you are new to remapping keys in vim.
imap <Bs> BACK
imap <Del> DELETE
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With