jpalardy/vim-slime

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.

nickeisenberg opened this issue ยท 9 comments

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?

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

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?

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.

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.

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>

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

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!

Excellent โ€” I'm glad you found a working combination ๐ŸŽ‰