Arrow keys type in capital letters instead of moving the cursor

I installed the latest vim using homebrew and also installed mac-vim from the google homepage. in mac-vim everything works fine. but when I run vim in terminal.app on mac and go into insert mode, I get ABCD for the arrow keys, which is extremely annoying.

I looked through it and tried all the solutions, but nothing works for me!

it becomes interesting when I start vim with vim -u NONE -U NONE -N , then the arrow keys start to function normally in insert mode.

My vimrc files are clones of janus (from carlhuda)

Do you have the same problem in the terminal? is there any way to fix it in terminal.app?

+25
vim terminal macos
Nov 29 '10 at 12:47
source share
13 answers

Just create an empty .vimrc file in the home directory of the remote machine. He started working great for me.

 touch ~/.vimrc 
+44
Dec 26 '12 at 13:35
source share

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

:set nocompatible

+18
Dec 6 '10 at 11:11
source share

This works for me:

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

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

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

This may also work:

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

Further information is available here.

+11
May 17 '11 at 2:20
source share

I work on a MacBook Pro with OSx El Captain (version 10.11.1) and experienced the same problem after updating my Vim with Homebrew.

My version of Vim is 7.4.1063.

I had a problem with the Terminal application, as well as with the iTerm application (build 2.1.4).

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

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

 set nocompatible set backspace=indent,eol,start 

The arrow and delete / return keys now work as expected. I did not need to change my $TERM env variable, as suggested in some previous answers.

I hope this helps others with the same problem.

+9
Jan 15 '16 at 10:22
source share

I am using iTerm2 with spf13-vim and have the same problem today.

This is caused by the removal of the vim-autoclose plugin. This decision fixed it.

Just add the following lines to your .vimrc

 if &term[:4] == "xterm" || &term[:5] == 'screen' || &term[:3] == 'rxvt' inoremap <silent> <C-[>OC <RIGHT> endif 
+7
May 19 '15 at 10:38
source share

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

export TERM = linux

+6
Nov 29 '10 at 13:04 on
source share

To make sure my terminal works fine with Vim 7.3 in Show Leopard, I did the following:

  • Installed the latest Vim via Homebrew .
  • Set the path to enable the latest Vim. For example: export PATH=/usr/local/bin:$PATH
  • Added export TERM=linux to my .bashrc file.
  • Created a .vimrc file with some parameters (previously linked here, the link is a thing of the past.)

When this is done, everything should work. However, I experienced that some text doesn't seem to be deleted, like its protected one, until I dd or x . Has anyone experienced something like this? Also, please share the comments on my little tutorial above.

+4
Jan 02 '10 at 17:12
source share

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

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

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

+2
Dec 28 2018-11-11T00:
source share

I used the following code in my .vimrc file and it solved the arrow problem.

 ... ... " Use Vim settings, rather than Vi settings (much better!). " This must be first, because it changes other options as a side effect. set nocompatible " allow backspacing over everything in insert mode set backspace=indent,eol,start ... ... " CTRL-U in insert mode deletes a lot. Use CTRL-G u to first break undo, " so that you can undo CTRL-U after inserting a line break. inoremap <CU> <CG>u<CU> " In many terminal emulators the mouse works just fine, thus enable it. if has('mouse') set mouse=a endif ... ... 

I posted my full .vimrc file here . Hope this helps!

+2
Apr 17 '12 at 15:45
source share

None of this helped me. Running vim empty with vim -u NONE -U NONE -N made it work fine, and since I didn't have any plugins, I knew the problem was in my vimrc. So I started commenting on sections, and at one point the problem disappeared.

The culprit was this line: inoremap

Even if it was recommended in a very well-written course ( http://learnvimscriptthehardway.stevelosh.com/chapters/10.html ), it broke the arrow keys in Mac OS X 10.10.In principle, you should not overwrite esc, as explained another SO answer: How to disable Esc and cursor keys in vim

+2
Dec 10 '14 at 16:28
source share

I had a similar problem with another plugin. I solved this by hard-coding these alternative mappings in the script itself, the first line of each pair was problematic, the second line is a 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>" 

^[ obtained by pressing <Cv><Esc> .

Perhaps you can try something like:

 map <Right> ^[OC 
+1
May 11 '11 at 4:55
source share

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

+1
Mar 18 '14 at 15:04
source share

I ran into this problem. It has several reasons, but one of them is vim, using the default behavior of vi, not vim. Surprisingly, this can be caused 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 the default vi values. With Mac Terminal, this will give you ABCD of arrows in insert mode. Add "set nocompatible" to the system-wide vimrc, which will force vim to use the default vim values ​​and the arrows will work again.

0
May 13 '11 at 17:59
source share



All Articles