Mac OSX iTerm: Arrow Key Not Working in VI/VIM

If your arrow keys are not working with iTerm during using VI/VIM.
Try add this line into /etc/bashrc or .profile

TERM=linux

After that

source ~/.profile (if you edit in .profile)
source /etc/bashrc (if you edit in bashrc)

Arrow keys working in VI/VIM now? Good luck