Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I recently upgraded from OS X 10.6 (I think) to 10.9. Since then it seems, while editing in vim, the arrow keys will "spontaneously" stop working.

At one point, in frustration I "mashed" one of the arrow keys and was eventually shown a "E388 Couldn't find a definition" error. All other times I've experienced it, the arrows, having worked for awhile, suddenly start dinging at me!

Quitting and reopening solves the problem temporarily. But, I'd like to prevent it!

Anyone know what this might be? And how to fix it?


It looks like my default vimrc was modified during the update. If my memory is correct, it was a pretty big file previously. Now, it just contains this:

" Configuration file for vim
set modelines=0         " CVE-2007-2438

" Normally we use vim-extensions. If you want true vi-compatibility
" remove change the following statements
set nocompatible        " Use Vim defaults instead of 100% vi compatibility
set backspace=2         " more powerful backspacing

" Don't write backup file if vim is being called by "crontab -e"
au BufWrite /private/tmp/crontab.* set nowritebackup
" Don't write backup file if vim is being called by "chpass"
au BufWrite /private/etc/pw.* set nowritebackup

I have no idea what these options do yet. I'll look into it -- but, hopefully someone here knows more quickly than I can google and read ...

share|improve this question
    
I also just realized there's an Apple-centric forum here that this question might be better suited for. So, if this is more likely a condition of OS X than vim, perhaps a mod could migrate this for me. –  svidgen Feb 22 at 3:55
1  
Reminds me of working on a "Prime" mainframe in college. The professor taught that you should never use the arrow keys in vi. Always use hjkl. That's where the "arrow" keys use to be on ancient hardware. –  Red Cricket Feb 22 at 3:56
    
OK... But, the arrow keys should work. Regardless of whether your professor thinks I should use them. And I find them convenient at times. So, looking forward to see the solution. –  svidgen Feb 22 at 15:28
1  
what happens when you insert the key literal into a buffer? go into insert mode, and press Ctrl+v, then an arrow key. Vim on my Mac shows the up arrow key as ^[OA, down as ^[OB, right as ^[OC, and left as ^[OD. check before and after the problem presents itself –  Nathan Wallace Feb 26 at 18:21
    
@NathanWallace not sure how I overlooked your question. I'll try that when I'm at my Mac next. –  svidgen Mar 4 at 4:53

3 Answers 3

This sounds very much like your issue. The article is titled: Cursor Keys in Vim: You Mac’ing Me Crazy!.

excerpt

Vim is useful in many situations, particularly for quick edits (especially as root), and editing files on a remote server. One annoyance I've had during my nine months with a Mac Book Pro is cursor keys in Vim ringing the bell in both insert or command mode instead of changing lines. Upgrading to version 7 via MacPorts yielded the same results. The cursor keys worked after switching my TERM to VT220 from rxvt! The downside was syntax highlighting stopped working.

Luckily, adding VT220 to my Google search parameters turned up a reference to vt100-cursor-keys in the Vim documentation. Add the following code to your .vimrc file to fix the problem:

    :set notimeout          " don't timeout on mappings
    :set ttimeout           " do timeout on terminal key codes
    :set timeoutlen=100     " timeout after 100 msec

In the same article there's another suggestion of setting your $TERM to linus instead on OSX.

excerpt

A better solution is to change the default value for TERM to either linux or dtterm since the TERM value will be picked up on the remote server. In this day and age, I would bet most servers support both these terminal types.

share|improve this answer
    
Hmm ... I'm even more confused now. I'd thought I had global/default .vimrc files. Would these have been moved or removed during an OS X update? –  svidgen Mar 5 at 2:35
    
@svidgen - No I don't think that would've changed, but that issue sounded er-rely similar to yours, and the fix is easy enough to try out, so I thought I'd share it with you. Incidentally the $TERM could've gotten changed on you. –  slm Mar 5 at 2:39
    
Whelp, this is definitely the most relevant answer here. +1 for that. Not sure whether it fixes it yet, unfortunately, since I can't consistently reproduce the problem. –  svidgen Mar 5 at 3:07
    
After having applied this fix, the issue has occurred again. Still a relevant answer, leaving the +1. But, please see my comment above if you're interested in supplying an additional answer. –  svidgen Mar 9 at 3:43

Congrats on the update. I did my own update over the weekend and have been dealing with some of my own odd keyboard issues.

Here are a couple of things I needed to to:

  • Remove old Logitech gaming software and upgrade. Prior to doing this I was having issues using my square and curly braces. Special keys often send esc-[ sequences in the VIM context so this might be relevant.
  • Go into System Prefs:Security and Privacy:Privacy:Accessibility and enable a couple of apps (synergy_server and Logitech gaming software). Prior to this change I was unable to control my other computers with synergy or use macros with my G11. I doubt this is a direct connection for you but the Accessibility options are new and might apply to some other app of yours.
share|improve this answer

If you are working in .sql files in vim (you don't mention) this could help you. I just dealt with this the other day.

In file ~/.vimrc

let g:omni_sql_no_default_maps = 1

this particular issue is discussed here

If you're not experiencing this problem with .sql files in vim then I apologize, my only thought would be to verify the mapping within vim when the problem occurs.

:map Ctrl V → when you lose your ability to use your arrow, do that command and see if the mapping disappeared. if it did, this gives you a place to start digging in.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.