Friday, May 13, 2016

Re: Disabling arrow key in insert mode

On Fri, May 13, 2016 at 12:19 PM, Thomas R. <thomas.j.rubeli@gmail.com> wrote:
> Hello,
>
> I'm trying to disable the arrow keys in insert mode. I added the following in my vimrc:
>
> inoremap <Left> <Esc>
> inoremap <Right> <Esc>
> inoremap <Up> <Esc>
> inoremap <Down> <Esc>
> inoremap <PageUp> <Esc>
> inoremap <PageDown> <Esc>
>
> When I'm in insert mode, I now can't navigate left and right.
> However, and I press up or down, the cursor still moves and I can still navigate.
>
> Any idea how that could be?
>
> Thank you
>

Try using <Nop> instead of <Esc> as the {rhs} of your mappings.
See :help <Nop>

The above mappings would all put you back in Normal mode, where
additional arrow presses would work.

This said, why do you want to disable arrow keys in Insert mode? Since
hjkl insert characters then, you would have to escape back to Normal
mode (either by <Esc>, do something, a or by Ctrl-O to do one
Normal-mode command), or to use the mouse, whenever you really want to
move the cursor. It regularly happens to me to notice that I made a
typo earlier in the current word, and then the easiest way to go back
and correct is by means of the arrow keys.


Best regards,
Tony.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: