Open mikatpt opened 3 months ago
I would add in addition to this the capacity to paste directly from CopyMode
, without resorting to exiting it each time for a paste. This defeats the purpose when one is using CopyMode
for multiple things outside of a one-shot copy/paste. Alacritty implements this very well. It would be nice to see WezTerm support it as well:
https://github.com/user-attachments/assets/777d1721-0397-42fc-8590-550f599c4bb9
In Alacritty, I enter Vim mode, hit y
to yank something (and still remain in Vim mode), then repeatedly hit p
to paste it while still staying in Vim mode, where I can continue being in, making other selections, etc.
Small update here. TLDR workaround available for everything except search mode always starting at bottom of terminal. Allowing search forwards/backwards from Copy Mode cursor location would resolve all remaining issues.
I've realized that Search mode cursor behavior is the primary issue here (1 and 3 in my initial post) - terminal output only causes a scroll to bottom if you have a pattern in your Search buffer. New output will continuously cause the search to retrigger and throw you back down - I'm not sure if this is intended but seems like a bug to me.
I do really wish this could be configurable - something like act.CopyMode({ SearchFromCursor = 'Forward|Backward' })
would put me at perfect feature parity with tmux.
As it is, my compromise is to clear the search pattern in all contexts that matter to me - moving between windows/tabs, initiating new searches will both start fresh, and thus no more cursor problems. (I also fixed issue 2 with a small timeout workaround).
Extend above config with the below example for this functionality:
local function complete_search(should_clear)
return wezterm.action_callback(function(window, pane, _)
if should_clear then
window:perform_action(act.CopyMode('ClearPattern'), pane)
end
window:perform_action(act.CopyMode('AcceptPattern'), pane)
-- For some reason this just does not work unless we retry a few times.
-- Probably something to do with state management between Search/Copy mode.
for _ = 1, 3, 1 do
wezterm.sleep_ms(100)
window:perform_action(act.CopyMode('ClearSelectionMode'), pane)
end
end)
end
local function clear_and_move(cmd)
return act.Multiple({
act.CopyMode('ClearPattern'),
cmd,
})
end
c.keys = {
-- ...
{ key = 'l', mods = 'CTRL', action = clear_and_move(act.ActivatePaneDirection('Right') },
-- repeat for hjkl,
{ key = 'n', mods = 'CTRL', action = clear_and_move(act.ActivateTabRelative(1) }, -- etc
}
c.key_tables.search_mode = extend_keys(default_keys.search_mode, {
{ key = 'Escape', mods = 'NONE', action = complete_search(true) },
{ key = 'Enter', mods = 'NONE', action = complete_search(false) },
})
Is your feature request related to a problem? Please describe.
Hi! Thanks for such a lovely project. I'm coming from tmux land and 90% of things are peachy, but there's a few things with search that I'm having a lot of difficulty working around.
Copy Mode
, the stdout output will cause your cursor position to move with the output—this happens regardless of scrollback buffer size.Search Mode
toCopy Mode
is a pain—it always throws you straight into selection (Visual
mode for vim users), and there is no way to clear it. i.e.ClearSelectionMode
andSetSelectionMode
only work if you're already inCopy Mode
, running those afterActivateCopyMode
will fail.CopyMode
, it's pretty unexpected to go into search and be thrown all the way back.Describe the solution you'd like
I saw there was a request for a unified search/copy mode ( https://github.com/wez/wezterm/issues/1592 ), but am unsure that the solution came to totally did this—I think that removing search mode entirely, in favor of combing it as functionality in copy mode, is a more ergonomic solution here.
For us vim users, it's very natural to feel like you are simply in normal mode and you can navigate around, search using
/
and?
, then select/copy withv
andy
—tmux did this quite well and it's the one thing I miss from it a lot!Aside from that I'm very pleased with everything—thanks again for your hard work.
Describe alternatives you've considered
Here are my copy mode bindings. It's imperfect, allowing me to sort of mimick vim "normal mode"—again, there's no solution I found to going
Search Mode -> Normal Copy Mode
, onlySearch -> Selection Copy Mode