Feat: Add caret mode for keyboard-driven navigation of the scrollback#12326
Open
brianc442 wants to merge 1 commit intoghostty-org:mainfrom
Open
Feat: Add caret mode for keyboard-driven navigation of the scrollback#12326brianc442 wants to merge 1 commit intoghostty-org:mainfrom
brianc442 wants to merge 1 commit intoghostty-org:mainfrom
Conversation
Uses VIM hotkeys as the default. The implementation is functionally the same as vim visual mode or the copy mode found in tmux & WezTerm. Written as an optional feature which is off by default. Requires a simple one line addition to the config file to create a keybind which activates caret mode.
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.
Directly related discussions: #3708 #3488
Less directly related but still relevant discussions: #2394 #6916 #6917 #7672
The caret appears as a hollow block cursor. Vim hotkeys are used by default. The implementation is functionally the same as vim visual mode or the copy mode found in tmux & WezTerm. One notable deviation from vim visual mode is that pressing
yto copy the selection does not exit caret mode - this was a deliberate design decision as exiting caret mode redraws the screen at the cursor which may not be desired if the user was copying something several pages up in the scrollback.Written as an optional feature which is off by default. Requires a simple one line addition to the config file to create a keybind which activates caret mode:
e.g.
keybind = alt+v=enter_caret_modeThe built in key table can be extended or overridden in ghostty/config (e.g.
keybind = caret/w=...). All defaults can be cleared withkeybind = caret/if desired.Default keybinds:
h/j/k/l or arrows: move caret
pg up/Ctrl+u/b: page up
pg dn/Ctrl+d/f: page down
gg/G: top/bottom of scrollback
0/$: beginning/end of line
/: search
n/N: search next/prev
v: toggle selection mode on/off (unlike vim, does not exit caret mode)
y: copy selection
Esc/q/i: exit caret mode
Code written with assistance from Claude Code. I reviewed, tested on Arch Linux, & ran the feature locally for ~1 month before submitting. It should work on macOS as well but I do not have a machine to test this.