Scripting
Gnome Terminal And Vi
It seems that on Ubuntu particularly, vi acts oddly. When you are in insert mode and use the cursor keys, you get characters (with \n) instead. To prevent this :
echo set nocompatible >> ~/.vimrc