hyper icon indicating copy to clipboard operation
hyper copied to clipboard

Text Navigation (Ctrl + arrow)

Open jritsema opened this issue 7 years ago • 24 comments

When editing text (coming from a windows background), I like to use Ctrl+left/right arrow for jumping from word to word. I'd like to be able to do this in Hyper as well.

I've been able to get this behavior on mac by using a DefaultKeyBinding.dict (Karabiner is currently broken on mac sierra)...

"^\UF702" = "moveWordBackward:";
"^\UF703" = "moveWordForward:";

...since electron-based apps obviously don't respect DefaultKeyBinding.dict, I got this to work in atom (keymap.cson) using...

'ctrl-left': 'editor:move-to-beginning-of-word'
'ctrl-right': 'editor:move-to-end-of-word'

It looks like there's some discussion around adding something like this to hyper, but in the meantime, anyone else run into this or have any solutions to offer? Thanks.

jritsema avatar Nov 28 '16 04:11 jritsema

@jritsema alt+left arrow or alt+right arrow should work for this

timothyis avatar Nov 28 '16 15:11 timothyis

Right, but I want to use the control key rather than alt.

jritsema avatar Nov 28 '16 16:11 jritsema

The issue there is that ctrl + left arrow controls desktop management on macOS, so that'd be a conflict.

timothyis avatar Nov 28 '16 16:11 timothyis

True, but I've disabled that in mac preferences (mission control), and like I said, I've enabled it in atom (another electron based app) using their keymap.cson support. I'm also able to get this behavior in iTerm2 (since they support keyboard mappings) but would prefer to use Hyper.

I wouldn't have posted this if I felt it was a very niche personal request. I'm guessing there is a significant percentage of former windows developers using mac that would appreciate the ability to change keyboard mappings.

I also looked at using the hyper-keymap plugin but it only allows mapping keys to the limited Hyper-specific commands (like new-window, close-window, etc.). I understand this ask might be complex to implement since I'm wanting to change keys inside the terminal.

At any rate, this PR by the same author as hyper-keymap looks promising.

jritsema avatar Nov 28 '16 16:11 jritsema

That's a good point. It's been a very popular request here to support custom keymaps and that feature could help you here. Although, I think @rauchg prefers that functionality in a plugin (though not completely sure). Perhaps he could chime in.

timothyis avatar Nov 28 '16 16:11 timothyis

Thanks @CodeTheory. Curious what @rauchg thinks. Perhaps this doesn't belong inside Hyper since it will be possible once Karabiner gets updated for sierra. But still might be a slick enhancement.

jritsema avatar Nov 28 '16 16:11 jritsema

Even on Windows, I can't seem to get Ctrl+Arrow to work, or Alt+Arrow.

cjb5790 avatar Dec 21 '16 16:12 cjb5790

Neither Ctrl + Arrow or Alt + Arrow are working for me on Windows either

Xapphire13 avatar May 26 '17 19:05 Xapphire13

This seems like an issue that's been around for months (Alt + Arrow navigations).

Spaxe avatar Jul 31 '17 01:07 Spaxe

you can now configure keyboard shortcuts for hyper commands:

https://github.com/zeit/hyper/blob/7f804cf66cd948357471333bccf39e0abc9a844b/app/keymaps/darwin.json

i guess the solution is to either add editor:move-to-beginning-of-word to hyper or write an extension

lorensr avatar Oct 29 '17 07:10 lorensr

Default OSX keys are not the same as Windows. OSX alt+left is normal, but on Win its normal to use ctrl + left/right. Even though configurations/plugins could solve this, I think you should think how the normal OS UX is and go from there instead.

Alt+Left/Right works on Windows, but are non standard behavior

hknielsen avatar May 16 '18 11:05 hknielsen

But what are the state then for ctrl+left/right to be configurable, so I can do that?

hknielsen avatar May 16 '18 11:05 hknielsen

@lorensr yeah a config like that would be perfect 👌

TylerLeonhardt avatar Jun 06 '18 18:06 TylerLeonhardt

I too would very much like an option to get Ctrl+Arrow working. I use it all the time in other apps and it's kinda annoying when I automatically try it in Hyper only to remember once again that it's not supported.

petmat avatar Jun 07 '18 06:06 petmat

So it looks like there IS an option for this: https://github.com/zeit/hyper/blob/2.0.0/app/keymaps/win32.json#L42-L43

but it doesn't seem to work for me. Can anyone get this to work?

TylerLeonhardt avatar Jun 09 '18 04:06 TylerLeonhardt

To share some history, binding Ctrl+Arrow to word movement in terminal apps is has been standard on Linux for quite some time, and (IIRC) was actually also the default movement binding for Terminal.app on macOS prior to the release of Spaces in 10.5 (when Apple decided to set a default binding for switching spaces).

Maybe I'm showing my age here, but I've always disliked how macOS automatically binds this keyboard shortcut for switching spaces, and have therefore always unbound it. Old habits die hard, I suppose, and in fact I hadn't even realized until now that macOS's Terminal.app defaults to using Option+Arrow for word movement, because I've always rebound Ctrl+Arrow to work for that.

It would be nice if we could rebind Ctrl+Arrow to word movement in Hyper on either macOS or Windows. 🙂

mattlubner avatar Aug 11 '18 20:08 mattlubner

I'm used to doing fn+left/right to go to beginning/end of line, which also doesn't seem to work. Any suggestions? Thanks!

marcooliveira avatar Aug 14 '18 16:08 marcooliveira

@marcooliveira, I assume on your keyboard fn+ maps to Home, and that fn+ maps to End. In which case, those are working fine for me (on Windows)

Xapphire13 avatar Aug 15 '18 00:08 Xapphire13

@marcooliveira ctrl+a and ctrl+e moves the cursor to the beginning and end of a line.

kellyp avatar Sep 27 '18 16:09 kellyp

ctrl + right and ctrl + left does also not work for me. I have explicitly set the keymap in the configuration, however alt + arrow key instead works

Kigamba avatar Jun 29 '19 21:06 Kigamba

Same here I can't get this to work on linux.

peymanmortazavi avatar Feb 11 '20 17:02 peymanmortazavi

So it looks like there IS an option for this: https://github.com/zeit/hyper/blob/2.0.0/app/keymaps/win32.json#L42-L43

but it doesn't seem to work for me. Can anyone get this to work?

I'm running hyper terminal on Windows, and the following method is working for me (Change keymaps, use cmd+left instead of ctrl+left):

I open the keymap file by pressing the hamburger menu on the left-top corner, then press "Edit", then press "Preferences..." to open the " ~/.config/Hyper/.hyper.js" https://hyper.is/#keymaps

Scroll to the bottom of the hyper.js and you will see the snippet of keymaps like this: keymaps: { // Example // 'window:devtools': 'cmd+alt+o', },

Then you add the following key-value into the keymaps snippet (Notice that it isn't ctrl+left or ctrl+right. Just use cmd instead of ctrl ): 'editor:movePreviousWord': 'cmd+left', 'editor:moveNextWord': 'cmd+right'

It turns out to be like this: keymaps: { // Example // 'window:devtools': 'cmd+alt+o', 'editor:movePreviousWord': 'cmd+left', 'editor:moveNextWord': 'cmd+right' },

Then you can use ctrl + left or ctrl + right to move word in the terminal.

tsinflam2 avatar May 27 '21 02:05 tsinflam2

So it looks like there IS an option for this: https://github.com/zeit/hyper/blob/2.0.0/app/keymaps/win32.json#L42-L43 but it doesn't seem to work for me. Can anyone get this to work?

I'm running hyper terminal on Windows, and it is working for me (Change keymaps, use cmd+left instead of ctrol+leftt):

I open the keymap file by pressing the hamburger menu on the left-top corner, then press "Edit", then press "Preferences..." to open the " ~/.config/Hyper/.hyper.js" https://hyper.is/#keymaps

Scroll to the bottom of the hyper.js and you will see the snippet of keymaps like this: keymaps: { // Example // 'window:devtools': 'cmd+alt+o', },

Then you add the following key-value into the keymaps snippet (Notice that it isn't ctrl+left or ctrl+right. Just use cmd instead of ctrl ): 'editor:movePreviousWord': 'cmd+left', 'editor:moveNextWord': 'cmd+right'

It turns out to be like this: keymaps: { // Example // 'window:devtools': 'cmd+alt+o', 'editor:movePreviousWord': 'cmd+left', 'editor:moveNextWord': 'cmd+right' },

Then you can use ctrl + left or ctrl + right to move word in the terminal.

2021-05-27 10_25_48-Window 2021-05-27 10_32_13-Window

tsinflam2 avatar May 27 '21 02:05 tsinflam2

adding the keymaps does not work in macos

    keymaps: {
    // Example
    // 'window:devtools': 'cmd+alt+o',
        "editor:movePreviousWord": "ctrl+left",
        "editor:moveNextWord": "ctrl+right",
    },

tbh I think the app should respect the DefaultKeyBinding.dict as per os settings support. Minimum would be that hyper actually applies the changes in it's own configuration.

Also my config is in ~/.hyper.js not in ~/.config/Hyper/.hyper.js

andreamarucciamambu avatar Jun 18 '22 13:06 andreamarucciamambu