Alt+key not working in embedded terminal

Answered

For instance, ALT+F and ALT+B works in the editor for moving the caret to start of next and previous word respectively. However, in the embedded terminal this is not working - though the chain ESC-ESC-F and ESC-ESC-B provides the same functionality I would really prefer to use the aforementioned.

Is there a way to have ALT+F and ALT+B work in the embedded terminal? Disabling mneumonics does not appear to solve the problem.

PhpStorm 2016.3.2
Ubuntu 16.04

 

35 comments
Comment actions Permalink

For the people using zsh

Add this to ~/.zshrc:

bindkey "\e\eOD" backward-word
bindkey "\e\eOC" forward-word

38
Comment actions Permalink

In order to activate ALT-LEFT & ALT-RIGHT in the terminal (as they work in bash), add the following to your ~/.inputrc:

"\e\e[C": forward-word
"\e\e[D": backward-word

and.. reopen the terminal within IntelliJ.

27
Comment actions Permalink

I should have mentioned: I am using Emacs keymap.

ALT+F should move the caret to the start of the next word, and ALT+B should move the caret to the start of the previous word, same functionality as CTRL+RightArrow and CTRL+LeftArrow respectively. I'd like to point out that this (ALT+F and ALT+B) works well in the editor, my problem is that I can't get it to work in the embedded terminal.

Override IDE shortcuts in File | Settings | Tools | Terminal is true/checked/active. After your comment I have also tried with Override IDE shortcuts disabled, but it made no difference.

 

3
Comment actions Permalink

Adding to "~/.inputrc" doesn't work for me.

The only shortcuts working are Esc+B/F that are very uncomfortable.

I managed to have both Opt+B/F and Opt+arrows in iTerm2 and I'd like to have them also in IntelliJ Terminal

3
Comment actions Permalink

~/.inputrc worked great for me on OSX

3
Comment actions Permalink

benjamin GUEZ solution didn't work for me. I use zsh with mac OS Catalina Version 10.15.3 on PyCharm 2019.3.2 Build Build #PY-193.6015.41.

However, i found a thread with a solution that worked for me: https://youtrack.jetbrains.com/issue/IDEA-165184?_ga=2.164760255.14018606.1580937565-184060322.1580438498

I had to put these lines into my ~/.zshrc

# fix for navigation keys in JetBrains terminal
if [[ "$TERMINAL_EMULATOR" == "JetBrains-JediTerm" ]]; then
  bindkey "∫" backward-word # Option-b
  bindkey "ƒ" forward-word # Option-f
  bindkey "∂" delete-word # Option-d
fi

3
Comment actions Permalink

Probably the cause is that I use zsh.
"Zsh does not use readline, instead it uses its own and more powerful Zsh Line Editor, ZLE. It does not read /etc/inputrc or ~/.inputrc"

2
Comment actions Permalink

Please try disabling the "Preferences | Tools | Terminal > Use Option as Meta key" option, that should help.

Just in case:
https://youtrack.jetbrains.com/issue/IDEA-274574

2
Comment actions Permalink

This is why PHPStorm's embedded terminal sucks.

1
Comment actions Permalink

~/.inputrc works great!Thanks

1
Comment actions Permalink

What keymap are you using (alt+f brings File menu by default)?

Do you have Override IDE shortcuts disabled in File | Settings | Tools | Terminal?

 

0
Comment actions Permalink

 I had the same issue.Why not fix it?

0
Comment actions Permalink

https://youtrack.jetbrains.com/issue/IDEA-153536 - this seems to be related bug report. Please vote/follow it to receive updates on it's progress

0
Comment actions Permalink

~/.inputrc solution did not work for me too

0
Comment actions Permalink

@Clarence What version of IntelliJ and OSX are you on?

0
Comment actions Permalink

@Andybergon Sierra 10.12.6 and Webstorm 2017.2.5, before I made the inputrc file alt+left and right would result in [C and [D in the terminal.

Added this file, and opened a new terminal and it worked.

 

0
Comment actions Permalink

I noticed that Opt+Left/Right add C or D and not [C or [D.

What can cause this? What should I put in the "~/.inputrc" file?

"\e\eC": forward-word
"\e\eD": backward-word

 

0
Comment actions Permalink

That's curious, for me SHIFT+LEFT and RIGHT add C or D, maybe a keyboard setting?

For example I need to use my fn key to use my top bar controls, e.g. media controls.

0
Comment actions Permalink

@Andybergon, is it possible that it pasted with smart quotes? These nasty quotes aren't called smart for no good reason - they're there to mess with you.

0
Comment actions Permalink

Any chance you made it work with zsh? I'm stuck with this issue too. 

0
Comment actions Permalink

Nope :V
I am really thinking about going back to bash as I use the terminal in IntelliJ a lot...

0
Comment actions Permalink

I am using bash on mac and adding the shortcuts inside (newly created) ~/.inputrc helped in my case! Thanx a lot! 

0
Comment actions Permalink

benjamin GUEZ thanks a lot!

0
Comment actions Permalink

Benjamin GUEZ you beauty....

Thanks a lot!

 

Would be nice if IntelliJ supported this out the box.

0
Comment actions Permalink

I modified ` ~/.inputrc` as someone commented above and ALT+Arrow works just fine. But now SHIFT+CMD+[ and SHIFT+CMD+] are not working to switch between terminal tabs :D

0
Comment actions Permalink

~/.inputrc worked for me on OSX Mohave and 2018.3

0
Comment actions Permalink

@benjamin GUEZ - that worked, thanks!

0
Comment actions Permalink

For me the solution made by @Moshe Bixenshpaner works fine! 

MacOS version: macOS High Sierra 10.13.4 
PHPStorm version: 2018.2.1

0
Comment actions Permalink

Thanks @Moshe Bixenshpaner, that .inputrc fixed it for me!

0

Please sign in to leave a comment.