HOME and END keys don't work in iex

HOME and END keys don’t work in my iex running on Ubuntu 18.04:

iex
Erlang/OTP 22 [erts-10.7.1] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [hipe]
Interactive Elixir (1.10.3) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)>

When the HOME key is pressed, nothing happens.
When the END key is pressed, a ‘~’ is typed.

The ‘Delete’ key works fine.

The same is seen in my Erlang shell.

How to fix it? Thanks.

Hello and welcome,

try ctrl-a and ctrl-e…

Hi kokolegorille,

ctrl-a and ctrl-e work perfectly as HOME and END respectively in my iex as well as my erlang shell, thanks!

Still they are not as convenient as HOME and END keys, is there anything I can tweak to make HOME and END keys work?

They are subset of Emacs shortcuts…

from http://erlang.org/documentation/doc-5.3/doc/getting_started/getting_started.html

Key Sequence Function
C-a Beginning of line
C-b Backward character
M-b Backward word
C-d Delete character
M-d Delete word
C-e End of line
C-f Forward character
M-f Forward word
C-g Enter shell break mode
C-k Kill line
C-l Redraw line
C-n Fetch next line from the history buffer
C-p Fetch previous line from the history buffer
C-t Transpose characters
M-t Transpose words
C-y Insert previously killed text

I think it’s easier to learn some Emacs, than to make HOME and END keys work :slight_smile:

2 Likes

Hello all, sorry to revive such an old post, but I got this very same issue working under urxvt terminal emulator (aka rxvt-unicode) and went down the rabbit hole digging for this in the source code of Elixir and later Erlang shells, and I found Home/End keys are working for Erlang shell erl since Oct 2015, and so they are working under Elixir shell iex too.

Tested several terminals and on mostly all of them both the Home and End keys work fine.

This is the list of terminals that have working Home and End keys:

And the non-working ones I found were:

Since many people use urxvt I wanted to post this, because I went down several hours hunting for a fixing in the source code, when in fact this is already implemented and is not an issue.

Finally, I’ve tried configuring my ~/.Xresources file for urxvt but didn’t have luck, tried:

! URxvt.keysym.Home: \033[1~
! URxvt.keysym.End: \033[4~
! URxvt.keysym.Home: \033[1
! URxvt.keysym.End: \033[4
! URxvt.keysym.Home: \033<C-a>
! URxvt.keysym.End: \033<C-e>
! URxvt.keysym.Home: \033[<C-A>
! URxvt.keysym.End: \033[<C-E>
! URxvt.keysym.Home: <C-a>
! URxvt.keysym.End: <C-e>
! URxvt.keysym.Home: <C-A>
! URxvt.keysym.End: <C-E>
URxvt.keysym.Home: \033[7~
URxvt.keysym.End: \033[8~

Uncommenting the one to try, opening a new urxvt terminal and reloading resources with xrdv ~/.Xresources, but none of them worked.

If anyone solves this for urxvt please reply to this post. Thanks.

1 Like