Wednesday, May 26, 2021

Re: Insert non-rectangular selection

On 5/25/21 4:54 PM, Andre Tann wrote:
> I repeatedly have the following situation, and wonder how it
> can be handled better than I do it now. These lines must be
> merged
>
> /path;text
> /path;text
> /path;text
>
> with these:
>
> /subdir
> /longsubdir
> /longlongsubdir
>
> Result:
>
> /path/subdir;text
> /path/longsubdir;text
> /path/longlongsubdir;text
>
>
> What I do now is to mark and yank the second block, go to the
> first semicolon, and press P. Result is:
>
> /path/subdir        ;text
> /path/longsubdir    ;text
> /path/longlongsubdir;text
>
> But this is obviously not what I want. How can I avoid the
> extra blanks?

One option might be to remove the spaces after pasting.
Assuming that none of the paths themselves contain a semi-colon,
you could visually select the lines of text and run this
substitute command::

  :'<,'>s/ *;/;/

This finds zero or more spaces followed by a semi-colon and
replaces with just the semi-colon.  It has no ``g`` flag, so
this applies only to the first semi-colon on each line (which
will always exist in your situation and by assumption won't be
found in the paths).

Michael Henry

--
--
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 on the web visit https://groups.google.com/d/msgid/vim_use/753cc134-cef6-67a2-9596-9d51e0ab26d2%40drmikehenry.com.

No comments:

Post a Comment