I'm using putty to ssh to Ubuntu with TERM=xterm-256color.

Inside vim, the home and end keys are not working properly. "Home" key makes vim enter in "Insert" mode and put a 'w' character. Similarly "End" key makes vim enter in "Insert" mode before putting a 'q' character.

The keys work fine outside vim. Home and End key puts the cursor at the beginning of the line or end of the line.

Also, this does not happen when I log in with TERM=linux set. Home and End keys inside vim function properly then.

  • This type of problem almost invariably comes down to the escape sequences being sent for various special keys. Check to make sure $TERM on the host you are connecting to corresponds to the settings in your PuTTY connection profile.
    – user
    Dec 24, 2016 at 12:31
  • @MichaelKjörling It's the same "xterm-256color" in both putty configuration as well in the host. Same behavior with xterm.
    – tcpip
    Dec 24, 2016 at 12:41
  • @MichaelKjörling I also tried editing escape sequences both by editing the terminfo file, compiling and exposing $TERMINFO variable. And also via editing /etc/vim/vimrc file and setting the proper values for both Home and End keys. No luck.
    – tcpip
    Dec 24, 2016 at 12:42

3 Answers 3


Finally. After hours of scouring the internet I stumbled upon something which I should've done much earlier.

Fixed it by checking "Disable application keypad mode" inside Terminal -> Features in PuTTY configuration. Answering it now for anyone who faces this problem.


Using export TERM=putty-256color solved my case for Ubuntu 20 with Putty.

Source: https://github.com/neovim/neovim/issues/4809


I got this behavior when I changed to screen-256color or tmux-256color, so I didn't want to change my terminfo.

If you like me are happy with your TERM setting you can also do a quick fix to reconfigure and as follows:

:set <Home>=<press Ctrl-V><press Home>
:set <End>=<press Ctrl-V><press End>

Above set <Home>= is a literal text you input, while the rest is what you press on your keyboard. Pressing Ctrl-V+Key adds the literal characters that result from pressing a key.

Trial and then add the above commands to your .vimrc to make the change permanent. You can also test the TERM variable:

if $TERM =~ '\v^(screen|tmux).*'
  set <Home>=^[OH
  set <End>=^[OF

Above the \[ is a single character, which won't work to copy-paste directly.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .