Enhance the capabilities of ctrl-l and the goto action#2522
Open
xyproto wants to merge 1 commit intomicro-editor:masterfrom
Open
Enhance the capabilities of ctrl-l and the goto action#2522xyproto wants to merge 1 commit intomicro-editor:masterfrom
xyproto wants to merge 1 commit intomicro-editor:masterfrom
Conversation
cc063d7 to
1f50d33
Compare
After pressing ctrl-l: * If at the bottom of the file and return is pressed, jump to the top. * If at the top of the file and return is pressed, jump to the bottom. * Typing in a percentage (like "50%") jumps to the center line. * Typing in a ratio (like ".5" or "0.5") jumps to the center line. Ratios like "0,5" and ",5" are also supported, since some languages use a comma instead.
dmaluka
reviewed
Sep 10, 2023
| } | ||
| targetLocation := buffer.Loc{0, int(math.Round(float64(h.Buf.End().Y) * ratio))} | ||
| h.Cursor.Deselect(true) | ||
| h.Cursor.Loc = targetLocation |
Collaborator
There was a problem hiding this comment.
Please note that for goto (and generally for cases where the new location may be far away from the old location) you should use h.GotoLoc() rather than just set the new location and relocate. See #2628.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
After pressing
ctrl-l:50%) jumps to the middle of the file..5or0.5) jumps to the middle of the file.Ratios like
0,5and,5are also supported, since some languages use a comma instead.I've used this functionality almost daily for a couple of years with my little editor
o, have become addicted to the workflow and wanted to share it, since I really appreciate themicroeditor.