DavidLGoldberg / jumpy

The fastest way to jump around files and across visible panes in Atom
https://atom.io/packages/jumpy
MIT License
124 stars 16 forks source link

Add support for custom label keys #111

Closed taylon closed 6 years ago

taylon commented 6 years ago

Since our finger is already on 'shift' after a jumpy activation I find it much easier to reach for keys like 'a, s, d, q, w, e, z, x, c' which are super closer to my fingers at that point than the default alphabetic order. So I implemented a custom keys option that allow to customize it.

Unfortunately I didn't have much time so I didn't include tests and did it in the simpler way possible, which enables the feature really well, but let me know if you think something should change and I can try to find some time for it =D

DavidLGoldberg commented 6 years ago

Dude, I was skeptical until I looked at the code, looks pretty awesome. I'll look at it more later...I'll try to add some tests. Unclear how it handles overflows? Does my existing code just properly check length? At one point I had some hard coded const's based on the math of the 26x26 and that 3x for the different casings etc...I do think the new code uses lengths...I'll start playing with this this weekend. Awesome job man! If this works out well, maybe I can look at getting some functionality more like vimium where it optimizes for less jump points. I'm kind of a fan of ordering but yeah we'll see.

BTW, next up on the list is getting elm in the code base to replace some of the state machine stuff....and then add another "labeler" for tree view....and then getting Jumpy into VS Code as well. Hit me up in gitter if you want to work on any of this :)

DavidLGoldberg commented 6 years ago

@taylon FYI: https://github.com/DavidLGoldberg/jumpy/commit/b077009e16cc910f4926100ab672d30915ddbe5d?w=1

Basically, I added support for hot swapping of the key set. It's usually less than a millisecond on my machine to run the set again. This also lets me get rid of the _.clone I had in there.

Added a test too.

Thanks so much for the good work!

lydell commented 6 years ago

Just tried out 4.2.0. Thank you so much for this feature! 🎉

DavidLGoldberg commented 6 years ago

You're welcome & Thanks @taylon ! But I have to be honest with you guys...I still don't really see the use case for this feature :\

I accepted it because:

  1. It was nice succinct code
  2. Doesn't add too much complexity to Jumpy's code at all
  3. Didn't break existing tests
  4. Was able to make a test for it

I tried it though with like my home keys, and didn't make much sense as I had to use shift more frequently. The uppercase feature in Jumpy is just there for when you have a lot of code on the screen...

With the reduced characters in the customKeys that numerical limit gets hit much earlier...

So, I'm curious...

What kind of programming languages are you guys working with. Are you using a certain real world language (spoken language)? Or just English?

Do you both 'touch-type' ....that is...type without looking at the keyboad.

By the way, I don't really use shift+enter. I use a tip that someone came up with on the boards in the early days of jumpy (can be found on the readme) of binding it to f when using vim-mode!

lydell commented 6 years ago

The uppercase feature in Jumpy is just there for when you have a lot of code on the screen...

I had no idea that this uppercase feature even existed! I’ve never encountered it. Just out of curiosity, I temporarily set the keys to a,b,c,d, and that did cause labels with uppercase letters to appear. Cool.

With the reduced characters in the customKeys that numerical limit gets hit much earlier...

I guess you chose too few customKeys, then. This is my set:

e, h, s, t, i, r, n, o, a, m, u, p, c, w, l, f, g, d, y

They are the letters I find the easiest to type in my keyboard layout, in descending order of easy-to-type-ness. Most notably this excludes keys I don’t like typing, such as z and x. I’ve used this set of keys for years in the VimFx Firefox extension.

What kind of programming languages are you guys working with.

JavaScript, CSS, Python, Elm. I also write HTML (templates), markdown and plain text.

Are you using a certain real world language (spoken language)? Or just English?

Not sure what you mean here? I mostly deal with English, but also Swedish.

Do you both 'touch-type' ....that is...type without looking at the keyboad.

Yes, I touch type.

By the way, I don't really use shift+enter. I use a tip that someone came up with on the boards in the early days of jumpy (can be found on the readme) of binding it to f when using vim-mode!

I don’t use shift+enter either. I’ve bound Jumpy to - in vim-mode-plus.

DavidLGoldberg commented 6 years ago

Thanks @lydell !

I use vimium for the browser myself, love it.

I do similar languages + a bunch of SQL.

Cool that you work on Elm too, I don't know if you read what I wrote above, but I'm going to release a '5.0' soon with Elm as the state machine. It's all the same from user side but significant architectural changes and I'll also try to add in jumping to the tree-view elements, so big enough for me and everyone else to call it a 5.0 I think :p

I'm trying to write the state-machine.elm so that it can be a git sub module used in a vs code version of Jumpy (haven't started that side yet though.

I may one day call upon your elm skills (I'm a beginner, although, it's almost about to get in Jumpy!)

I just need to figure out how to get Jasmine to respect the async nature of the elm ports. At least, that's what I think is going on :)

DavidLGoldberg commented 6 years ago

btw, going to try out your keys, thanks!

DavidLGoldberg commented 6 years ago

Oh. Lol. This is looking good already (smh). Let me use it for a week or two and probably throw it in the README.md.

Maybe one day it'll be the default :P

DavidLGoldberg commented 6 years ago

But yeah, the limitation of a lot more jump points than is typically present on a browser (like vimium) deters me from getting into the optimization game that vimium plays with single letters etc... I don't want to get into that.

In vimium 1 char is often enough... in Jumpy the 2 char rhythm I wouldn't want to lose that per se with scattered 1 chars.

(fun fact, a jumpy user turned me on to vimium had never seen it before!)

After I get tree view and ported to vs code....if anything I'm going to look at adding in beginning of line / end of line....empty lines should implicitly handle the case of those lines with certain characters like { } ( ) etc.

lydell commented 6 years ago

Maybe one day it'll [lydell’s keys] be the default

No, please don’t do that! My set of keys is optimized for my own, custom keyboard layout (anishtro). If you are going to change the default keys I’d suggest VimFx’s default keys, which are optimized for QWERTY:

fjdkslaghrueiwoncmv

Interesting to hear about your Elm plans! Feel free to ping me, and I might be able to help out some time. I do have a habit of taking on too much open source work, though.

DavidLGoldberg commented 6 years ago

Ah ok, yeah let me try the VimFx's!!

DavidLGoldberg commented 6 years ago

Yes. Starting to see how these could win :)

taylon commented 6 years ago

The keys I'm currently using are "a, s, d, q, w, e, z, x, c, r, f, v". Those are the keys I find easier to reach with my left hand which is positioned very close to them when I activate jumpy (I use shift+enter)

With that amount of keys I have seen the capitalized ones a couple of times but not too much, and I could add a couple more keys if I really wanted to avoid it, so in general it works great for me =D

Since we now have the custom keys I think that the alphabetic order is a good default, maybe some documentation explaining what to take into consideration when thinking about what keys to choose would be cool.

DavidLGoldberg commented 6 years ago

@taylon Yeah, feel free to make another PR for the README.md. Personally, I'll let it simmer for a while, see how it goes etc... Oh. I just realized we never even added a line for the settings section in the readme at all. A one liner would be nice in the settings and maybe another section towards the bottom.

Note: I think the section about Hydrogen is so important, since it's so big now. Hydrogen I love it, but they sure do hijack a gazillion hotkeys.

lydell commented 6 years ago

Btw, why are the custom keys comma separated? Would be easier to just type abcd than a,b,c,d.

DavidLGoldberg commented 6 years ago

I agree. I might do that via string split and add a comment in the readme for a 4.2.1 or something

On Mon, Dec 11, 2017, 1:36 AM Simon Lydell notifications@github.com wrote:

Btw, why are the custom keys comma separated? Would be easier to just type abcd than a,b,c,d.

— You are receiving this because you modified the open/close state.

Reply to this email directly, view it on GitHub https://github.com/DavidLGoldberg/jumpy/pull/111#issuecomment-350634629, or mute the thread https://github.com/notifications/unsubscribe-auth/AAjTr1SZA9wyDU12xHXp_GvNDmsaHpBeks5s_M1ygaJpZM4Q4j2V .