Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

acidity

macrumors regular
Original poster
Sep 7, 2006
115
0
Hi

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.
 
Hi

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.

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 :)
 
yes i fixed this issue on mine by doing the following

1) sudo cp /etc/bashrc /etc/bashrc (backs up the file)

That doesn't back up any file. That overwrites the file with itself.

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 :)

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'.
 
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!
 
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!

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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.