New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(Re)-binding \cj breaks enter key #217

Closed
chdorner opened this Issue Jul 9, 2012 · 10 comments

Comments

Projects
None yet
10 participants
@chdorner

chdorner commented Jul 9, 2012

I wanted to have vim key mappings instead of the arrows with the following commands:

bind \ch 'backward-char'
bind \cl 'forward-char'
bind \ck 'up-or-search'
bind \cj 'down-or-search'

Which seems to work great, except that because of re-binding of the \cj key combination, the enter key stopped working.

Is that intended behavior or a bug?

@ridiculousfish

This comment has been minimized.

Show comment
Hide comment
@ridiculousfish

ridiculousfish Apr 15, 2013

Member

ctrl+j is line feed, so it inserts the same thing as return. So when you bind to ctrl-j, you bind to return as well. This may be unfixable.

Member

ridiculousfish commented Apr 15, 2013

ctrl+j is line feed, so it inserts the same thing as return. So when you bind to ctrl-j, you bind to return as well. This may be unfixable.

@padde

This comment has been minimized.

Show comment
Hide comment
@padde

padde Sep 20, 2013

I stumbled upon this one too. As Vim user I hate to take the trip to the arrow keys ;-) I wonder how ZSH does it, because it works there. With the following mapping, ZSH somehow still manages to distinguish between ctrl+J and .

bindkey "^J" history-search-forward

padde commented Sep 20, 2013

I stumbled upon this one too. As Vim user I hate to take the trip to the arrow keys ;-) I wonder how ZSH does it, because it works there. With the following mapping, ZSH somehow still manages to distinguish between ctrl+J and .

bindkey "^J" history-search-forward
@jimtla

This comment has been minimized.

Show comment
Hide comment
@jimtla

jimtla May 29, 2014

As a workaround for this issue I used iterm2 to send the escape squence [18~ on \cj, and then added bind -k f7 down-or-search to my fish_user_keybindings. I'm sure you can do something similar in any other terminal emulator.

jimtla commented May 29, 2014

As a workaround for this issue I used iterm2 to send the escape squence [18~ on \cj, and then added bind -k f7 down-or-search to my fish_user_keybindings. I'm sure you can do something similar in any other terminal emulator.

@beloglazov

This comment has been minimized.

Show comment
Hide comment
@beloglazov

beloglazov Jun 5, 2014

@jimtla I couldn't make this work with urxvt.

Vim also manages to distiguish <C-j> and <CR>, so it should be possible.

@jimtla I couldn't make this work with urxvt.

Vim also manages to distiguish <C-j> and <CR>, so it should be possible.

@michaeljones

This comment has been minimized.

Show comment
Hide comment
@michaeljones

michaeljones Nov 29, 2015

+1, I've experienced the same situation coming to fish with a history of vim. I like home row key bindings and it has been possible one way or another in zsh & tcsh. I can see there is a clear argument for them being indistinguishable but if it is possible in any standard way then it just makes things more flexible, I think.

+1, I've experienced the same situation coming to fish with a history of vim. I like home row key bindings and it has been possible one way or another in zsh & tcsh. I can see there is a clear argument for them being indistinguishable but if it is possible in any standard way then it just makes things more flexible, I think.

@krader1961

This comment has been minimized.

Show comment
Hide comment
@krader1961

krader1961 Nov 29, 2015

Contributor

The reason \cJ seems to insert the same thing as [enter] is because the tty is in cooked mode with icrnl enabled -- that causes the tty driver to map carriage-return (aka \cM and [enter]) to newline (aka \cJ). See http://stackoverflow.com/questions/14615717/how-can-vim-tell-the-difference-between-ctrl-j-and-lf

I vote that fish disable icrnl mode so that \cJ can be rebound.

Contributor

krader1961 commented Nov 29, 2015

The reason \cJ seems to insert the same thing as [enter] is because the tty is in cooked mode with icrnl enabled -- that causes the tty driver to map carriage-return (aka \cM and [enter]) to newline (aka \cJ). See http://stackoverflow.com/questions/14615717/how-can-vim-tell-the-difference-between-ctrl-j-and-lf

I vote that fish disable icrnl mode so that \cJ can be rebound.

@krader1961

This comment has been minimized.

Show comment
Hide comment
@krader1961

krader1961 Nov 30, 2015

Contributor

P.S., I'm working on a change to implement this (i.e., separate \cJ from \cM) on UNIX. TBD is what, if anything, needs to change for MS Windows.

Contributor

krader1961 commented Nov 30, 2015

P.S., I'm working on a change to implement this (i.e., separate \cJ from \cM) on UNIX. TBD is what, if anything, needs to change for MS Windows.

@michaeljones

This comment has been minimized.

Show comment
Hide comment
@michaeljones

michaeljones Nov 30, 2015

Thanks for the update! You've helped me realise that that is what I'm seeing as well. I think it has been sufficient for me on other shells to distinguish between \cJ and \cM which means being able to distinguish between Enter and \cJ as well as they don't represent the same input.

I saw that stackoverflow question too but unfortunately I am not wise in the lingo of terminal programming. I would welcome any help on this and would be happy to try to test something if you have a fork I could look at. Thanks again!

Thanks for the update! You've helped me realise that that is what I'm seeing as well. I think it has been sufficient for me on other shells to distinguish between \cJ and \cM which means being able to distinguish between Enter and \cJ as well as they don't represent the same input.

I saw that stackoverflow question too but unfortunately I am not wise in the lingo of terminal programming. I would welcome any help on this and would be happy to try to test something if you have a fork I could look at. Thanks again!

@faho

This comment has been minimized.

Show comment
Hide comment
@faho

faho Nov 30, 2015

Member

I vote that fish disable icrnl mode so that \cJ can be rebound.

@krader1961: Doesn't that just move the problem to \cm? At least that's how I understood the SO answer.

Of course \cj is probably slightly more usual, what with vi-bindings and all, but it's not a real solution.

Member

faho commented Nov 30, 2015

I vote that fish disable icrnl mode so that \cJ can be rebound.

@krader1961: Doesn't that just move the problem to \cm? At least that's how I understood the SO answer.

Of course \cj is probably slightly more usual, what with vi-bindings and all, but it's not a real solution.

krader1961 added a commit to krader1961/fish-shell that referenced this issue Nov 30, 2015

allow \cJ (\n) to be bound separate from \cM (\r)
This makes it possible (on UNIX systems, don't know about MS Windows)
to bind \cJ (\n) independently of \cM (\r, aka [enter]).

Resolves #217

@zanchey zanchey modified the milestones: next-2.x, fish-future Dec 15, 2015

liefswanson added a commit to liefswanson/ergo-emacs-fish-key-bindings that referenced this issue Sep 9, 2017

liefswanson added a commit to liefswanson/ergo-emacs-fish-key-bindings that referenced this issue Sep 9, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment