Friday, August 28, 2015

Re: Copy text and Paste at multiple lines

On Saturday, August 29, 2015 at 2:36:43 PM UTC+12, ali jaan wrote:
> Say i had a text like this
> baseline string a;
> baseline b;
> baseline c;
> baseline d;
>
> I need to have like this
> baseline string a;
> baseline string b;
> baseline string c;
> baseline string d;
>
> Q1.I wanted to copy "string" and Paste across different lines at a single
> shot .How can i do this.?

If, as in your example, the lines are contiguous, read on.

visual block put. See :help v_p. It's a bit tricky, but will do the job. First yank the text you want to copy, then start a visual block down the spaces at the end of "baseline", and press p. The pasted string will *replace* the visual block, and you can't have a zero width block. If you want to keep the contents of the block, press p again.

> Q2.I wanted to copy a text from "unix terminal/from different Vim file".How
> can i paste that string in multiple lines at a single shot?

Again tricky, the setting of the 'clipboard' or 'guioptions' settings interfere.
You probably have "a" for "autoselect" in guioptions, which means when you start the block mode, the contents of the block becomes the X selection, forgetting the text you want to paste. If you have "autoselect" on:
- You can use the X "clipboard"; at the source, after selecting do an explicit "Copy" operation (like you have to on Windows). Then, after making your visual block, use "+p to paste from the clipboard.
- You can copy the text to be pasted before starting the visual block. One way is to paste it (using "*p or middle-mouse) and immediately delete it. Another,
:let @" = @* "copies the selection to the unnamed register

HTH, John Little

--
--
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.
For more options, visit https://groups.google.com/d/optout.

No comments: