Giter Club home page Giter Club logo

jumpy2's Introduction

Jumpy2

A VS Code extension that creates dynamic hotkeys to jump around files across visible panes. It's a new 'Jumpy' but from the original author (Atom package) for VS Code. It works with the major VSC vim extensions and I plan to maintain it.

How to jump

  1. Hit shift + enter
  2. Choose from your presented labels:
  3. Enter two characters.
  4. Keep coding!

Watch the demo:

Jumpy2 demo on youtube.com

Install

On command line:

code --install-extension davidlgoldberg.jumpy2

Notes

  • Works great with or without vim or neovim! See vim/nvim integration below
  • Vim modes supported:
    • command mode
    • insert mode
  • Recommended key mappings to replace 'f' in vim integration below.
  • Recommended key mappings for back and forward below.

Key Bindings

Defaults

  • Enter jump mode
    • shift + enter
  • Enter selection mode
    • shift + alt + enter
  • Reset first character entered
    • backspace
  • Cancel/exit jump mode (any of the following)
    • shift + enter
    • enter
    • esc
    • space

Jump back and forward

Did you know VS Code has built in backwards and forward navigation functionality? You should probably map that to a hotkey for Jumpy! I currently use the backspace key which overrides the default boring backspace functionality from vim (while in normal mode only of course).

For example with vim Edit this in your keybindings.json file:

    {
        "key": "backspace",
        "command": "workbench.action.navigateBack",
        "when": "editorTextFocus && vim.active && !inDebugRepl && vim.mode == 'Normal'"
    },
    {
        "key": "shift+backspace",
        "command": "workbench.action.navigateForward",
        "when": "editorTextFocus && vim.active && !inDebugRepl && vim.mode == 'Normal'"
    },

Custom set of keys to use (easier to type / faster?)

"jumpy2.customKeys": {
    "type": "array",
    "default": "fjdkslaghrueiwoncmv",
    "description": "Default characters to use"
},

The default might be easier for beginners. It is also probably better for larger screens (more labels before jumpy has to resort to utliizing uppercase letters).

"jumpy2.customKeys": {
    "type": "array",
    "default": "abcdefghijklmnopqrstuvwxyz",
    "description": "Default characters to use"
},

Colors & Border

To override Jumpy's default label colors (black on green) try this In your VS Code's settings.json file:

"workbench.colorCustomizations": {
  "jumpy2.labelFontColor": "#000000", // black
  "jumpy2.labelBackgroundColor": "#ff0000", // on red
  "jumpy2.labelBorderColor": "#ffffff", // white border
  "jumpy2.beaconColor": "#ff0000af", // transparent red
},

However, it is probably wise to leave the defaults, and instead scope this to a theme or wildcarded (modified from VS Code's examples like so:

"workbench.colorCustomizations": {
  // NOTE: not all dark and light themes are conveniently labeled "dark" or "light" like this.
  // In that case, you can specify per theme, or again, just leave Jumpy's default or override the default with the example above.
  "[*Dark*]": {
    "jumpy2.labelFontColor": "#000000",
    "jumpy2.labelBackgroundColor": "#FFFFFF",
    "jumpy2.labelBorderColor": "#FF0000",
    "jumpy2.beaconColor": "#FF0000AF",
  },
  "[*Light*]": {
    "jumpy2.labelFontColor": "#FFFFFF",
    "jumpy2.labelBackgroundColor": "#000000",
    "jumpy2.labelBorderColor": "#FF0000",
    "jumpy2.beaconColor": "#FF0000AF",
  }
},

Vim integration

(see neovim below if interested)

Override vim's extension level backspace

If you want the backspace key to work as the jumpy "reset" command you must define a "user" level keybindings override in keybindings.json to override vim's "extension" level keybinding:

{
    "key": "backspace",
    "command": "jumpy2.reset",
    "when": "jumpy2.jump-mode && editorTextFocus"
}

(feel free to bind it to another key as well)

Bind 'f' and/or 'F' key

if f vim functionality is desired: open settings as json and add:

  "vim.normalModeKeyBindingsNonRecursive": [
    {
      "before": ["f"],
      "commands": ["jumpy2.toggle"]
    },
    {
      "before": ["F"],
      "commands": ["jumpy2.toggleSelection"]
    }
  ],

Neovim Integration

NOTE: I haven't fully configured neovim but used it successfully for a while with the following:

{
  "key": "f",
  "command": "jumpy2.toggle",
  "when": "neovim.mode =~ /^normal$|^visual$/ && !jumpy2.jump-mode && editorTextFocus"
},
{
  "key": "escape",
  "command": "jumpy2.exit",
  "when": "neovim.init && jumpy2.jump-mode && editorTextFocus"
}

for back and forward functionality with neovim:

{
  "key": "backspace",
  "command": "workbench.action.navigateBack",
  "when": "editorTextFocus && !inDebugRepl && neovim.mode != 'insert'"
},
{
  "key": "shift+backspace",
  "command": "workbench.action.navigateForward",
  "when": "editorTextFocus && !inDebugRepl && neovim.mode != 'insert'"
}

Fun

See your achievements(!)

command palette (usually command/ctrl+shift+p) -> Jumpy: Show Jumpy Achievements (career jumps) (a real ninja would bind it to a key though)

You can also disable this pop up if you're an uber important 1337 10x h4x0r that can't afford to hot key a tab closed once a year...

  "jumpy2.achievements.active": false,

Emojis (Subtly useful)

Change the 'jumper' set (emojis) in your VS Code's settings.json

add:

  "jumpy2.jumperEmojis.jumperSet": ["๐Ÿ’"],

The above tells jumpy to use the monkey emoji exclusively.

Of course you can turn these off too. If you have no soul.

  "jumpy2.jumperEmojis.active": false,

Known Issues

  • Can not jump to treeview or tabs.

Acknowledgements

  • Various contributors from the original atom project.
  • Logo icon created by Dr. Gregory W. Goldberg (in his spare time!) and David L. Goldberg."
  • Implementation inspiration from Wayne Maurer (the author of the first VS Code implementation of Jumpy)

Related work

(should we collab more? Reach out!)

Keywords

(A little SEO juice)

  • Shortcuts
  • Navigation
  • Productivity
  • Mouseless
  • Plugin
  • Extension

My previous Atom packages :)

Support Jumpy2

jumpy2's People

Contributors

davidlgoldberg avatar dependabot[bot] avatar fredbill1 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

jumpy2's Issues

[Feature] Jump and bookmarks or memoize previous jumps

I'm going to propose this simple feature which memoize or bookmarks previous successful jumps

For example
I jumped to bc, then, if I'm editing another file or in the same file, bc will jump to the same place like if I had bookmarked
Here's an implementation 45b4de8

It could be a settings that can be true or false

What do you think?

Add Support for selection from to jump

When refactoring I sometimes want to move or cut a block of code.
Currently I am using the mouse or Shift + Arrows to select it.

But with Jumpy it would be so much faster.

Adding something like a modifier key to the jump which would select all text between the jump start and end would be really neat.

cannot see the second letter

Hi there,
thanks for making this extension!
there is an issue that it is very difficult to see the second letter of the label. Can you please make the label sizes bigger?
i.e. in the screenshot, it's difficult to figure out which letter comes after the b ....

image

Improved "accuracy"

I have several ideas for improving "accuracy". In the mean time I have included a conversation from the marketplace that fast forwarded some of this, by simply improving the regex (something I hadn't really attacked since the Atom version :-\ )

I have been using a newer regex for ~2 weeks and really love it so far. I will either change the default regex pattern (in the config) OR add it to the README.md etc

Thanks Tetsuo Rulin for steering me in this direction (https://marketplace.visualstudio.com/items?itemName=DavidLGoldberg.jumpy2&ssr=false#review-details):

One of the best VSCode extensions. Makes navigating so much easier.
My recommendation to other users is to instead of using the default regex pattern which is ([A-Z]+([0-9a-z])*)|[a-z0-9]{2,} which highlights the beginning of every word, simply use the ... regex pattern which highlights every 3 letters and in my opinion that's even more precise and makes navigation even faster, even though you can't always navigate to the beginning of the word, you can navigate to pretty much any part of your code within the distance of 0-2 characters, and that's for symbols too, not just words.

Edit:
Yep, I suggested ... but I think that's the same as .{3}. I tried something similar to [^\s]{1,3} but the problem is that not all matches are the same length so there are visual overlaps between the matches and it's kinda janky. I find ... works perfectly for me.

And you have guessed correctly haha, I do use neovim for vscode, but I use it non-traditionally since I'm very new to it and most of the time I'm in insert mode but that's also because I made some cool shortcuts and modifications that allow me to move quickly in insert mode. I disabled the default caps-lock action in my OS, and basically I have caps-lock + i,j,k,l shortcut as up, left, down, and right, so my right hand doesn't have to move to the arrow keys. And I even made caps-lock+ijkl work with shift and also with ctrl and alt so I can also select text with ijkl and also move by full words, not just by character. Pair this with jumpy2, and I'm pretty damn fast :D I basically just jump to a word and use shift+alt+L to select the whole word, or shift+alt+LL to select quotes or bracket content, or caps+shift+L to select a character right.

And mine:

Thanks for the awesome review/feedback!!!

I have a few ideas of how to improve this "accuracy" in general.

In the short term, I might add this and some others to the README.md or maybe to the settings/config as well.

Also, I am curious, do you use one of the vims for VSC?

[EDIT] ...I hadn't played with this regex/accuracy stuff in quite a while, are you suggesting:

.{3} ....?

I just tried that and it's kind of nice!

I just fumbled for a few mins and got:

[^\s]{1,3} <--- Pretty great so far!?

I am going to use that for a while to see how it goes! Thanks for getting my butt moving on the accuracy again!

These variants are particularly sufficient for vimmers where quick adjustments left and right are trivial.

BTW, some {2} variants are probably an option for some of these too...if you're a robot! Who knows maybe a bunch of people prefer it that way too. (Which is why the regex has always stuck around)

EDIT:
I missed your edit, I think (lol, the edit trick is weird going to switch to a github issue here:
#60
Please chime in over there :)

[FR] locality bonus: locations closer to the cursor should be "easier" to jump to

thanks for the extension!
if possible, locations closer to the cursor should be "easier" to jump to, sort of implementing a locality bonus.

By "easier" I mean, for example:

  1. jump to close locations via one letter jumps, and only in the range "asdfghjkl"
  2. jump to close locations via two letter jumps, and only in the range "asdfghjkl"

Locations farther away may use the rest of the alphabet, and also combination of lowercase/upperase letters, as is the case today.

Allow 'f'+'F' binding while in 'v' (visual) to enter selection mode

It'd be nice to allow the hotkeys to continue and pick up on the selection modes. (command palette works fine so it's just a binding precedence issue)

the 'f' key should also work to continue selection. Once the keybindings are worked out, 'f' should work IF #45 is already built.

Improve performance with large files

I have researched and have some branches with several ideas for performance improvements, but it's usuable right now for decent sized files, so going ahead with release!

wrong lineheight

WX20240607-095353

i use mac
FontSize: 12
FontFamily: Monaco

Editor Theme: Material Theme

Labels missing under open of a code fold (if no subsequent user input)

This is an odd edge case I found when my tests failed.

In the current version of VS Code, if you unfold a code block and then IMMEDIATELY open Jumpy2, the previously folded region will be missing the labels. Instead, if you first you move the cursor or click to focus on the editor it resumes working.

[Feature] Try to alternate hands when assigning codes to locations

When assigning codes to locations, first assign all the codes where each letter is on a different hand (e.g. go through fj, me, ic, etc. before using same handed codes like fr, gt, and dx, assuming qwerty layout) instead of just assigning them in order. This would make jumping around feel much quicker since I don't have to move the same hand twice.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.