:r! reply-body --top '/tmp/Re1BDLjSqOg3'
On Tue, 25 May 2021, Andre Tann <[email protected]> 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?

This is an interesting problem. I've personally found visual-block
yank / put most useful in ASCII art, where true rectangular blocks are a
feature. I see some tantalizing hints in the visual.txt help file about
padded with whitespace or not, but I can't get that to work for this
type of change.

Faced with a problem like this, I'd probably write a program to do the
change (possibly within the editor :'a,'e ! perl -wne '...' -- or
possibly as a separate true script), but I might also find a way to
do it with marks and macros. Maybe something like this tail-recursive
thing:

        :map ## maf;'b"aDddmb`a"aPj0##

Set up mark b at the start of the /subdir area, move to the start of
the /path;text area and start

        f;              find the ;, hopefully will error out at end
        ma              set mark a
        'b              jump to mark b (start of line)
        "pD             delete to end of line, stored in p
        dd              delete now blank line
        mb              set a new mark b
        `a              return to mark a (mid line, on ; )
        "pP             put buffer p
        j0              move to start of next line
        ##              recurse

(Untested.)

Elijah

-- 
-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/4FqzFM5wzZzfYm%40panix5.panix.com.

Reply via email to