Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cursor returns to the beginning of a selection when sending code from a script in one tmux pane to the terminal in the other terminal pane. #383

Open
nickeisenberg opened this issue Jul 6, 2023 · 8 comments

Comments

@nickeisenberg
Copy link

Suppose I select some text in order to send it to another terminal pane. If I select the text from top to bottom (ie the cursor is at the bottom of the selection when I send the text to the other tmux pane), then the cursor returns to the top where the selection started. Is there a way to not have this be the case and to keep the cursor in the exact location where I initiate the code sending?

@nickeisenberg
Copy link
Author

This is similar I believe to this issue. It is said that cursor preservation was added later on in the 'happy path'?

@jpalardy
Copy link
Owner

jpalardy commented Jul 7, 2023

Hi @nickeisenberg

Cursor save/restore goes through https://github.com/jpalardy/vim-slime/blob/main/plugin/slime.vim#L16

A few things:

  • your g:slime_preserve_curpos is unset or set to 1?
  • what key binding are you using?

@nickeisenberg
Copy link
Author

I just tried setting g:slime_preserve_curspos to both 0 and 1 and still had the same result. And I believe I am just usingthe standard key binding c-c c-c to send code to the other tmux pane.

@jpalardy
Copy link
Owner

jpalardy commented Jul 7, 2023

Before pressing c-c c-c, do you select text?

What I see

  • inside a paragraph, c-c/c-c, cursor stays where it is
  • select text, cursor on first line, c-c/c-c, cursor stays
  • select text, cursor on last line, c-c/c-c, cursor goes to first line (your case?)

the invocation, depending on selected or not, is different

Using '> after the c-c/c-c will move you to the selection end.

@nickeisenberg
Copy link
Author

nickeisenberg commented Jul 7, 2023

I never knew about '> but that is exactly what I wanted! I think im seeing here that c-c c-c is mapped to something called <Plug>SlimeRegionSend. Is there a way to instead map c-c c-c to <Plug>SlimeRegionSend '> so that the cursor automatically stays at the end of my selection>

@jpalardy
Copy link
Owner

jpalardy commented Jul 7, 2023

Is there a way to instead map [...] ?

Definitely 😄

But is '> what you always want to do after c-c/c-c?

I've done something similar to step through a bunch of paragraphs:

  • ctrlc, enter to call slime, then } and j, to move to the next paragraph

Let me know if you can make that work — if not, we can try a few things

@nickeisenberg
Copy link
Author

nickeisenberg commented Jul 7, 2023

I figured out what I needed! I did the following:

let g:slime_no_mappings = 1
xmap <c-c><c-c> <Plug>SlimeRegionSend <Esc> `>
nmap <c-c><c-c> <Plug>SlimeParagraphSend
nmap <c-c>v     <Plug>SlimeConfig

Thanks for the quick replies, I really appreciate it!

@jpalardy
Copy link
Owner

jpalardy commented Jul 8, 2023

Excellent — I'm glad you found a working combination 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants