Arrow keys type capital letters instead of moving the cursor

后端 未结 13 1662
失恋的感觉
失恋的感觉 2021-02-01 03:49

I\'ve installed the latest vim using homebrew and also installed mac-vim from the google code homepage. in mac-vim everything works fine. but when I run vim in terminal.app in m

相关标签:
13条回答
  • 2021-02-01 04:35

    I've run into this problem as well. It has multiple causes, but one of them is vim using vi rather than vim behavior by default. Surprisingly, this can be triggered by the location of your vimrc file.

    For example, if you delete your .vimrc from your home directory and move the contents to the system-wide vimrc file, vim will start using vi defaults. With the Mac Terminal, this will give you ABCD from arrows in insert mode. Add "set nocompatible" to the system-wide vimrc, which will force vim to use vim defaults, and the arrows will work again.

    0 讨论(0)
  • 2021-02-01 04:39

    This works for me:

    map ^[[A <up>
    map ^[[B <down>
    map ^[[C <right>
    map ^[[D <left>
    

    To type the sequence for each arrow key, you need to press ctrl-v, then the arrow key.

    For example, to type the first line:
    m, a, p, space, ctrl-v, , space, <, u, p, >

    This also might work:

    set t_ku=^[[A
    set t_kd=^[[B
    set t_kr=^[[C
    set t_kl=^[[D
    

    More information is available here.

    0 讨论(0)
  • 2021-02-01 04:41

    I'm using iTerm2 with spf13-vim, and have same problem today.

    It caused by removing plugin vim-autoclose. This solution fixed it.

    Just add following lines into your .vimrc

    if &term[:4] == "xterm" || &term[:5] == 'screen' || &term[:3] == 'rxvt'
      inoremap <silent> <C-[>OC <RIGHT>
    endif
    
    0 讨论(0)
  • 2021-02-01 04:49

    Just create an empty ".vimrc file in the home directory of the remote machine. It started working fine for me.

    touch ~/.vimrc
    
    0 讨论(0)
  • 2021-02-01 04:49

    This is what worked for me (based on initial solution from @Phoenix above)

    imap ^[OA <ESC>kli
    imap ^[OB <ESC>jli
    imap ^[OC <ESC>lli
    imap ^[OD <ESC>hli
    

    for each ^[
    type the sequence press ctrl-v, then ESC

    0 讨论(0)
  • 2021-02-01 04:51

    You need to set no compatible mode in the vim Try following command in normal mode

    :set nocompatible

    0 讨论(0)
提交回复
热议问题