Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable backspace and delete keys in Vim?

Tags:

vim

I'd like to use Vim for distraction-free writing instead of PyRoom/TextRoom. This post, which mentions VimRoom, could already show me how to get most settings.

I only miss how to enable TextRoom style flow mode:

How can I disable backspace and delete keys (not shortcuts like d$)?

like image 705
mcbetz Avatar asked Dec 06 '12 10:12

mcbetz


People also ask

How to map the backspace and delete keys in vimscript?

Does anyone know how to map the backspace and delete keys in Vimscript? Show activity on this post. 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:

Is it possible to Backspace in vimrc?

If your delete key terminal code is wrong, but the code for backspace is alright, you can put this in your vimrc: This works no matter what the actual code for backspace is. This is, at best, horrifically misleading.

How do I delete all VIM settings at once?

you do that by typing stty erase and then Ctrl - V and finally press the Delete key. Hope that fixes the problem. The weird behavior is still present. Show activity on this post. All the vim settings have to be done in a file called .vimrc located in $HOME.

Why can't I map to Ctrl-H in Vim?

This may be unintentional; Vim sees CTRL-H as a backspace (because CTRL-H is the ASCII code for a backspace), so you also cannot map anything to that. You can check if there are any mappings set, and where they came from, like this: If you find a mapping you can try clearing it with: If you want to create your own emergency mapping, you could try:


1 Answers

You can disable individual keys by mapping them to the special <Nop> target:

:inoremap <BS> <Nop>
:inoremap <Del> <Nop>

(Assuming you only want them disabled in insert mode.)

like image 129
Ingo Karkat Avatar answered Oct 03 '22 22:10

Ingo Karkat