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

Readline shortcuts in forms / insert mode #68

Open
The-Compiler opened this Issue Oct 1, 2014 · 14 comments

Comments

Projects
None yet
10 participants
@The-Compiler
Collaborator

The-Compiler commented Oct 1, 2014

It'd be nice to have readline shortcuts inside forms. However I'm not sure if it's possible to modify the cursor position etc.

@The-Compiler The-Compiler self-assigned this Oct 1, 2014

@NoSuck

This comment has been minimized.

Show comment
Hide comment
@NoSuck

NoSuck Mar 24, 2015

This would be a godsend.

NoSuck commented Mar 24, 2015

This would be a godsend.

@jahkeup

This comment has been minimized.

Show comment
Hide comment
@jahkeup

jahkeup Mar 25, 2015

Especially for Emacs users! 👍

jahkeup commented Mar 25, 2015

Especially for Emacs users! 👍

@The-Compiler

This comment has been minimized.

Show comment
Hide comment
@The-Compiler

The-Compiler Feb 7, 2017

Collaborator

FWIW you can do some of those things with bindings using the fake-key command:

:bind --mode=insert <Ctrl-a> fake-key <Home>
:bind --mode=insert <Ctrl-k> fake-key <Shift-End> ;; fake-key <Delete>
...

still I'm hesitant to add those bindings by default - I think most users would still expect e.g. ctrl-a to select all.

Collaborator

The-Compiler commented Feb 7, 2017

FWIW you can do some of those things with bindings using the fake-key command:

:bind --mode=insert <Ctrl-a> fake-key <Home>
:bind --mode=insert <Ctrl-k> fake-key <Shift-End> ;; fake-key <Delete>
...

still I'm hesitant to add those bindings by default - I think most users would still expect e.g. ctrl-a to select all.

@Al-Caveman

This comment has been minimized.

Show comment
Hide comment
@Al-Caveman

Al-Caveman Feb 7, 2017

Contributor

Personally I have (thanks to The-Compiler for tellng me over IRC):

:bind --mode=insert <Ctrl-a> fake-key <Home>
:bind --mode=insert <Ctrl-e> fake-key <End>
:bind --mode=insert <Ctrl-k> fake-key <Shift-End> ;; fake-key <Delete>

And this works perfectly for me so far.

Contributor

Al-Caveman commented Feb 7, 2017

Personally I have (thanks to The-Compiler for tellng me over IRC):

:bind --mode=insert <Ctrl-a> fake-key <Home>
:bind --mode=insert <Ctrl-e> fake-key <End>
:bind --mode=insert <Ctrl-k> fake-key <Shift-End> ;; fake-key <Delete>

And this works perfectly for me so far.

@Chinggis6

This comment has been minimized.

Show comment
Hide comment
@Chinggis6

Chinggis6 Apr 9, 2017

alias imap "bind --force --mode insert"
imap <Ctrl-h> fake-key <Backspace>
imap <Backspace> message-info "Use Ctrl-H!"

If you hate Backspace 😉

Chinggis6 commented Apr 9, 2017

alias imap "bind --force --mode insert"
imap <Ctrl-h> fake-key <Backspace>
imap <Backspace> message-info "Use Ctrl-H!"

If you hate Backspace 😉

@wsdjeg

This comment has been minimized.

Show comment
Hide comment
@wsdjeg

wsdjeg Nov 23, 2017

How about <Ctrl+w>? seems hard to bind.

wsdjeg commented Nov 23, 2017

How about <Ctrl+w>? seems hard to bind.

@wsdjeg

This comment has been minimized.

Show comment
Hide comment
@wsdjeg

wsdjeg Nov 23, 2017

:bind --mode=insert <Ctrl-u> fake-key <Shift+Home> ;; fake-key <Delete>

wsdjeg commented Nov 23, 2017

:bind --mode=insert <Ctrl-u> fake-key <Shift+Home> ;; fake-key <Delete>
@pkillnine

This comment has been minimized.

Show comment
Hide comment
@pkillnine

pkillnine Nov 23, 2017

@wsdjeg bind --mode insert <Ctrl-w> fake-key <Ctrl-backspace>

pkillnine commented Nov 23, 2017

@wsdjeg bind --mode insert <Ctrl-w> fake-key <Ctrl-backspace>

@krompus

This comment has been minimized.

Show comment
Hide comment
@krompus

krompus Dec 18, 2017

@pkillnine also, make sure you don't have <Ctrl-w> set to close tab; that caused me some headaches back on Pentadactyl before I unbound it. Then my issue was accidentally closing tabs when using default browsers. #justemacsproblems

krompus commented Dec 18, 2017

@pkillnine also, make sure you don't have <Ctrl-w> set to close tab; that caused me some headaches back on Pentadactyl before I unbound it. Then my issue was accidentally closing tabs when using default browsers. #justemacsproblems

@The-Compiler The-Compiler changed the title from Readline shortcuts in forms to Readline shortcuts in forms / insert mode Dec 19, 2017

@rndusr

This comment has been minimized.

Show comment
Hide comment
@rndusr

rndusr Sep 5, 2018

I think the fake-key hack should be documented in the FAQ or something.

Being forced to use the cursor keys until I found this issue was probably the
biggest hurdle for me. I had to find the fake-key hack and then figure out the
shortcuts, like . I would've been absolutely delighted to find
something like this:

c.bindings.commands = {
    'insert': {
        '<Ctrl-f>'        : 'fake-key <Right>',
        '<Ctrl-b>'        : 'fake-key <Left>',
        '<Ctrl-a>'        : 'fake-key <Home>',
        '<Ctrl-e>'        : 'fake-key <End>',
        '<Ctrl-n>'        : 'fake-key <Down>',
        '<Ctrl-p>'        : 'fake-key <Up>',
        '<Alt-v>'         : 'fake-key <PgUp>',
        '<Ctrl-v>'        : 'fake-key <PgDown>',
        '<Alt-f>'         : 'fake-key <Ctrl-Right>',
        '<Alt-b>'         : 'fake-key <Ctrl-Left>',
        '<Ctrl-d>'        : 'fake-key <Delete>',
        '<Alt-d>'         : 'fake-key <Ctrl-Delete>',
        '<Alt-Backspace>' : 'fake-key <Ctrl-Backspace>',
        '<Ctrl-y>'        : 'insert-text {primary}',
    }
}

rndusr commented Sep 5, 2018

I think the fake-key hack should be documented in the FAQ or something.

Being forced to use the cursor keys until I found this issue was probably the
biggest hurdle for me. I had to find the fake-key hack and then figure out the
shortcuts, like . I would've been absolutely delighted to find
something like this:

c.bindings.commands = {
    'insert': {
        '<Ctrl-f>'        : 'fake-key <Right>',
        '<Ctrl-b>'        : 'fake-key <Left>',
        '<Ctrl-a>'        : 'fake-key <Home>',
        '<Ctrl-e>'        : 'fake-key <End>',
        '<Ctrl-n>'        : 'fake-key <Down>',
        '<Ctrl-p>'        : 'fake-key <Up>',
        '<Alt-v>'         : 'fake-key <PgUp>',
        '<Ctrl-v>'        : 'fake-key <PgDown>',
        '<Alt-f>'         : 'fake-key <Ctrl-Right>',
        '<Alt-b>'         : 'fake-key <Ctrl-Left>',
        '<Ctrl-d>'        : 'fake-key <Delete>',
        '<Alt-d>'         : 'fake-key <Ctrl-Delete>',
        '<Alt-Backspace>' : 'fake-key <Ctrl-Backspace>',
        '<Ctrl-y>'        : 'insert-text {primary}',
    }
}
@jgkamat

This comment has been minimized.

Show comment
Hide comment
@jgkamat

jgkamat Sep 9, 2018

Collaborator
Collaborator

jgkamat commented Sep 9, 2018

@rndusr

This comment has been minimized.

Show comment
Hide comment
@rndusr

rndusr Sep 9, 2018

How about making this configurable with a boolean setting?

That snippet I posted above is a very elaborate "readline-keybindings =
True". There is no need to spell it out in every detail like that.

A setting would also solve the discoverability issue. It would be documented
together with the other settings and you could find it by searching for
"readline" on the settings reference page.

rndusr commented Sep 9, 2018

How about making this configurable with a boolean setting?

That snippet I posted above is a very elaborate "readline-keybindings =
True". There is no need to spell it out in every detail like that.

A setting would also solve the discoverability issue. It would be documented
together with the other settings and you could find it by searching for
"readline" on the settings reference page.

@The-Compiler

This comment has been minimized.

Show comment
Hide comment
@The-Compiler

The-Compiler Sep 9, 2018

Collaborator

Someone would first need to verify (ideally by writing tests) that those keybindings work as expected, and also do so on macOS and Windows. FWIW I'd still prefer a proper implementation of the same movements using JS though.

Collaborator

The-Compiler commented Sep 9, 2018

Someone would first need to verify (ideally by writing tests) that those keybindings work as expected, and also do so on macOS and Windows. FWIW I'd still prefer a proper implementation of the same movements using JS though.

@The-Compiler

This comment has been minimized.

Show comment
Hide comment
@The-Compiler

The-Compiler Oct 6, 2018

Collaborator

Another point raised in #4298: Some of those keybindings (like Ctrl-U) overwrite primary selection, which is unexpected - that wouldn't happen if this were properly implemented in JavaScript.

Collaborator

The-Compiler commented Oct 6, 2018

Another point raised in #4298: Some of those keybindings (like Ctrl-U) overwrite primary selection, which is unexpected - that wouldn't happen if this were properly implemented in JavaScript.

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