jpalardy / vim-slime

A vim plugin to give you some slime. (Emacs)
http://technotales.wordpress.com/2007/10/03/like-slime-for-vim/
MIT License
1.9k stars 227 forks source link

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 1 year ago

nickeisenberg commented 1 year ago

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 commented 1 year ago

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

jpalardy commented 1 year ago

Hi @nickeisenberg

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

A few things:

nickeisenberg commented 1 year ago

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 commented 1 year ago

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

What I see

the invocation, depending on selected or not, is different

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

nickeisenberg commented 1 year ago

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 commented 1 year ago

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:

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

nickeisenberg commented 1 year ago

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 commented 1 year ago

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