more improvements from @rafi and http://mightyuhu.github.io/blog/2011/04/19/uvxrt-vim-arrow-and-end-key-problem/