iTerm, vi with arrow movements

Discussion in 'Mac Apps and Mac App Store' started by acidity, Oct 8, 2007.

  1. acidity macrumors regular

    Sep 7, 2006

    I login to my company server through SSH using iTerm. There when I start vim, I cannot move my cursor using arrow keys. I have to use h,j,k,l.

    Any idea why does this happen? I can use the arrow keys when I login from Konsole on my other other machine.
  2. danwestbrook macrumors regular


    Oct 11, 2007
    Surrey, UK
    yes i fixed this issue on mine by doing the following

    1) sudo cp /etc/bashrc /etc/bashrc (backs up the file)
    2) sudo vi /etc/bashrc (used terminal not iterm)
    3) insert the following line "TERM=linux"
    4) save the file
    5) enjoy iterm and vi using the arrow keys :)
  3. Mumford macrumors regular


    Oct 8, 2006
    Altadena, CA
    That doesn't back up any file. That overwrites the file with itself.

    You shouldn't edit the system bashrc for this. Just edit ~/.bashrc. Also, use 'export TERM=linux' so the environment variable gets passed on to sub-shells. Or use 'vi -T linux'.
  4. TemeculaMac macrumors regular

    Aug 8, 2007
    My suggestion...learn to use the h,j,k, and l keys. Once you force yourself into using these, it's 10x faster moving around. Look at this hurdle as a perfect opportunity to sharpen those vi skills. There's no way you can get me to use the arrow keys now....

    Good luck!
  5. abackstrom macrumors newbie

    May 4, 2010
    The arrow keys are used for more than just moving the cursor around. They're how you navigate history (ie. searches and commands) and they're also used for some plugin menus. So, not quite as simple as "sharpen those vi skills."

    I needed to fix this live within vim, so I cycled through each of <xUp>, <xDown>, <xRight>, and <xLeft> doing this:

    :set <xUp>=(ctrl-V)(up arrow)

    Which output this on the screen:

    :set <xUp>=^[[A

    The ^[[A (or more specifically, the ^[) is a single terminal sequence rather than the character ^ followed by the character [; the ctrl-V causes the up arrow to be written out as text rather than treated as an action by vim.

Share This Page