You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 ↩.
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.
+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.
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!
Activity
ridiculousfish commentedon 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.
sugar700 commentedon Apr 15, 2013
http://stackoverflow.com/questions/14615717/how-can-vim-tell-the-difference-between-ctrl-j-and-lf
padde commentedon 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 ↩.
jimtla commentedon May 29, 2014
As a workaround for this issue I used iterm2 to send the escape squence
[18~on \cj, and then addedbind -k f7 down-or-searchto my fish_user_keybindings. I'm sure you can do something similar in any other terminal emulator.beloglazov commentedon 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.michaeljones commentedon 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.
krader1961 commentedon 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 commentedon 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 commentedon 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!
faho commentedon Nov 30, 2015
@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.
update dvorak for changes to fish (cj vs cM)
fix cj vs cM in qwerty