views:

58

answers:

1

I'm using vim in gnome-terminal (2.26.0): although I use 95% of the time "$" to navigate to the EOL and "0" for the opposite, every now and then I hit "Home" or "End". When I use Home, the text I have in the current line is moved on line down, leaving me in insert mode in the current line and the letter H appears at the beginning of the line. When I hit End, it's the same but with an F instead of H.

Why does it happen? How can I fix it? (fixing would mean to have the standard functionality when hitting these keys).

TIA, Mariano

+1  A: 

This happens because pressing the home and end keys in a terminal sends an escape sequence consisting of several characters to vim, and vim isn't correctly associating these escape sequences back with the keys you pressed.

To fix this you need to adjust the term setting. Gnome-terminal is xterm compatible, so you could try:

set term=xterm

The term setting is derived from the TERM environment variable, so you might want to investigate why it isn't set correctly in the first place.

Laurence Gonsalves
Had that setting in my .bashrc and I always assumed it was enough. I was obviously wrong. Thanks for your help.