Skip to content

Add optional relative line jumps to go-to-line action#46932

Merged
ConradIrwin merged 2 commits intozed-industries:mainfrom
KalaayPT:go-to-line-relative
Jan 27, 2026
Merged

Add optional relative line jumps to go-to-line action#46932
ConradIrwin merged 2 commits intozed-industries:mainfrom
KalaayPT:go-to-line-relative

Conversation

@KalaayPT
Copy link
Contributor

@KalaayPT KalaayPT commented Jan 15, 2026

Implements relative line jumping, a common feature i missed from Vim/Neovim where you can jump to lines relative to your current cursor position.

  • New {"relative": true} flag for go_to_line::Toggle action
  • Supports both -5 (5 lines up) and b5 (backward 5 lines) syntax
  • Full lines only (no column support in relative mode, wasnt sure if that would be necessary)
  • Unbound by default - users can add e.g. "ctrl-j": ["go_to_line::Toggle", {"relative": true}] to their keymap

Example usage:

  • 5 → jump 5 lines down
  • -3 or b3 → jump 3 lines up
  • 0 → stay on current line
Screencast_20260115_191312.webm

Release Notes:

  • Added relative line jump support to go-to-line action via +/-/f/b/F/B

@cla-bot
Copy link

cla-bot bot commented Jan 15, 2026

We require contributors to sign our Contributor License Agreement, and we don't have @KalaayPT on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'.

@zed-community-bot zed-community-bot bot added the first contribution the author's first pull request to Zed. NOTE: the label application is automated via github actions label Jan 15, 2026
@KalaayPT
Copy link
Contributor Author

@cla-bot check

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Jan 15, 2026
@cla-bot
Copy link

cla-bot bot commented Jan 15, 2026

The cla-bot has been summoned, and re-checked this pull request!

@maxdeviant maxdeviant changed the title feat: add relative line jumps to go-to-line action (optional) Add optional relative line jumps to go-to-line action Jan 15, 2026
@KalaayPT
Copy link
Contributor Author

but there are release notes?

@ConradIrwin
Copy link
Member

It's very picky about formatting!

Does this need to be an option, or could we have -3 and +3 always be supported in that modal for relative jumps?

@KalaayPT
Copy link
Contributor Author

KalaayPT commented Jan 15, 2026

It's very picky about formatting!

Does this need to be an option, or could we have -3 and +3 always be supported in that modal for relative jumps?

i would actually prefer it be an option because i would prefer not to have to type '+' every time. i already added 'b' as an alternative to '-' because its closer to the home row and you dont have to stretch as much, same for '+'

also added a newline after release notes in case that was the issue

@ConradIrwin
Copy link
Member

For that use-case you can bind "ctrl-g": ["workspace::SendKeystrokes", "ctrl-g +"], but then I guess you'd want to handle +b3 for backwards (though that seems reasonable, and is how vim's command palette handles chained +/-).

Actually, thinking about this more, did you know that :-3 and :+3` already do what you want?

@KalaayPT
Copy link
Contributor Author

Actually, thinking about this more, did you know that :-3 and :+3 already do what you want?

yeah but thats in vim mode, this is specifically for usage outside of vim mode

@ConradIrwin
Copy link
Member

Makes sense.

Ok, let's ship the version of this without the option. People who want to default to relative jump in the forward direction can add a mapping that uses workspace::SendKeystrokes; and we can make sure that the parser handles +- by taking the last direction (i.e. +- is backwards, -+ is forward, -- is backward to match vim).

I'm ok with having b as a shorthand for backwards (though maybe a similar for f would be good too).

(I also want to at some point significantly improve the UX of workspace::SendKeystrokes by giving it its own JSON syntax, but haven't done that yet)

@KalaayPT
Copy link
Contributor Author

KalaayPT commented Jan 15, 2026

am a little bit confused on the implementation youre proposing. would that essentially mean "if the user inputs multiple 'directions' we only take the last one"? just to accomodate the keybind you were proposing?
so any of "+++3", "--+3", "++--f3" would make a forward jump by 3?
i guess that works but then im wondering why not keep the default? either way you have to add a custom keymap. the steps for the end user are the same.
the way youre proposing ill have to edit this again to accomodate (not that thats a big issue but im wondering what the rationale is here, code simplicity?)

@ConradIrwin
Copy link
Member

I prefer it because it reduces the number of different states we have to maintain (the palette always works the same regardless of how you open it).

@KalaayPT
Copy link
Contributor Author

updated to implement what we discussed. + and - are now built into go-to-line directly and support +/-/f/b/F/B. also only takes the last direction so "+b2" still jumps backwards, accounting for custom keybinds inserting a '+'. should i update the description? or only release notes?

demo:
Screencast_20260116_111238.webm

@ConradIrwin
Copy link
Member

Thanks for the update, and sorry for not hitting merge sooner.

@ConradIrwin ConradIrwin merged commit e64985e into zed-industries:main Jan 27, 2026
25 checks passed
@KalaayPT KalaayPT deleted the go-to-line-relative branch January 27, 2026 11:53
naaiyy added a commit to Glass-HQ/Glass that referenced this pull request Feb 16, 2026
Key changes:
- Reopen with encoding (zed-industries#46553) - new encoding selector with reopen support
- Relative line jumps in go-to-line (zed-industries#46932)
- Terminal tab renaming (zed-industries#45800)
- Project search spinner while search underway (zed-industries#47620)
- Git: retain "since" diffs, avoid unwrap in panel, don't rebuild diff on repo change
- Extensions: fix duplicate button IDs preventing uninstall (zed-industries#47745)
- SendKeystrokes: don't use layout key equivalents (zed-industries#47061)
- Collab tests extracted to integration crate (deleted in our fork)
- Various CI, docs, and agent improvements

Conflict resolutions:
- Kept native_button style, adopted extension_button_id() for unique IDs
- Added encoding_selector::init alongside browser::init
- Fixed _cx → cx rename for new encoding selector render code

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement first contribution the author's first pull request to Zed. NOTE: the label application is automated via github actions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants