Arrow keys type capital letters instead of moving the cursor

后端 未结 13 1659
失恋的感觉
失恋的感觉 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:30

    I'm on a MacBook Pro with OSx El Captain (version 10.11.1) and was having the same problem after updating my Vim with Homebrew.

    My Vim version is 7.4.1063.

    I was having the problem with the Terminal app as well as the iTerm app (build 2.1.4).

    To solve this problem, I followed some of the instructions in the previous answers from @devsathish and @Kailash. The steps I followed were:

    1 - Create a .vimrc file with touch ~/.vimrc
    2 - Add the following to it:

    set nocompatible
    set backspace=indent,eol,start
    

    Now the arrow keys and the delete/backspace keys work as expected. I didn't have to change my $TERM env variable as suggested in some of the previous answers.

    I hope this helps others with the same problem.

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

    To make sure that my Terminal is working great with Vim 7.3 in Show Leopard, I have done the following:

    1. Installed the latest Vim via Homebrew.
    2. Set path to enable the latest Vim. E.g.: export PATH=/usr/local/bin:$PATH
    3. Added export TERM=linux to my .bashrc file.
    4. Created a .vimrc file with some options (formerly linked here, link went dead.)

    When so is done, everything should work. However, I have experienced that some text don't seem to remove, like its protected until I either dd or x. Has anyone experienced something similar? Also, please share comments on my small guide above.

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

    This is usually caused by the wrong $TERM environment variable. Not sure which ones are supported on your system but you can try with "linux" or "vt320":

    export TERM=linux

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

    None of the above worked for me. Running vim in blank state with vim -u NONE -U NONE -N made it work ok, and because I had not installed any plugins, I knew problem is in my vimrc. So I started commenting out sections from it, and at one moment problem disappeared.

    The culprit was this line: inoremap

    Even though it was recommended in a very well written course (http://learnvimscriptthehardway.stevelosh.com/chapters/10.html), it broke the arrow keys on Mac OS X 10.10. Basically, you shouldn't overwrite esc, as the other SO answer explains: How to disable Esc and cursor keys in vim

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

    I actually resolved this on OS X Mavericks (10.9) by removing set noesckeys from ~/.vimrc

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

    I've had a similar problem with another plugin. I solved it by hardcoding these alternative mappings in the script itself, the first line of each pair was problematic, the second line is the fix:

    VIM::command "#{map} <Right> :call <SID>#{prefix}KeyPressed(9)<CR>"
    VIM::command "#{map} ^[OC    :call <SID>#{prefix}KeyPressed(9)<CR>"
    
    VIM::command "#{map} <Left>  :call <SID>#{prefix}KeyPressed(23)<CR>"
    VIM::command "#{map} ^[OD    :call <SID>#{prefix}KeyPressed(23)<CR>"
    
    VIM::command "#{map} <Down>  :call <SID>#{prefix}KeyPressed(14)<CR>"
    VIM::command "#{map} ^[OB    :call <SID>#{prefix}KeyPressed(14)<CR>"
    
    VIM::command "#{map} <Up>    :call <SID>#{prefix}KeyPressed(16)<CR>"
    VIM::command "#{map} ^[OA    :call <SID>#{prefix}KeyPressed(16)<CR>"
    

    ^[ is obtained by hitting <C-v><Esc>.

    Maybe you can try something like:

    map <Right> ^[OC
    
    0 讨论(0)
提交回复
热议问题