Thursday, December 26, 2024

Re: Pasting large text in vim

On 2024-12-26 08:39, Enan Ajmain wrote:
> Ven Tadipatri wrote:
> > Now, there is some fine print that I should let people know. Your vim
> > compiler needs to be built with a "+clipboard" option.
>
> This is the sore point. For people who use Vim over ssh, this is not an
> option (ssh -X is crappy at least in my experience). OSC52 is a godsend
> for this, but it only works for copying not pasting (for security
> reasons). I've been dealing with it with ':set paste!' & <C-S-v>, but
> as you said, for large text that's problematic.
>
> So what I tend to do is: I send the clipboard content to a temp file
> over ssh and then use remote Vim's local register to copy from that temp
> file.

While kinda hackish, I tend to

:r !cat

then paste the contents into the terminal/ssh window (doesn't get
impacted by auto-indent) and then control+d to send the EOF when done.

> xclip -o | ssh enan@remote.org 'cat > tmp.txt' # from local shell
> # then copy content from tmp.txt to real-file.txt with Vim

It has the benefit that I don't need to clean up the temp-file when
done. Also, it works in vi/nvi on my BSD boxes that don't have vim, and
even works in ed(1) when I'm using that (though I do have to beware if
the pasted text has any lines consisting of only a period)

-tim





--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/vim_use/Z21hfqDsrJo4GTlz%40thechases.com.

No comments: