1

I have 3 blocks of text with the same number of lines that I want to merge each block by line.

# block 1
[ Card "Skwortul"    
, Card "Scorchander" 
, Card "Seedasaur"   
, Card "Kapichu"     
, Card "Elecdude"    
, Card "Garydose"    
, Card "Moisteon"    
, Card "Grasseon"    
, Card "Spicyeon"    
, Card "Sparkeon"    
]
# Block 2
Wet False
Hot False
Leafy False
Spark False
Spark False
Wet True
Wet False
Leafy False
Hot False
Spark True
# Block 3 
[Move "Squirt" 20]
[Move "Scorch" 20]
[Move "Allergize" 20]
[Move "Poke" 10 , Move "Zap" 30]
[Move "Asplode" 50]
[Move "Gary's move" 40]
[Move "Soggy" 3]
[Move "Leaf Cut" 30]
[Move "Capsaicisize" 40]
[Move "Shock" 40 , Move "Battery" 50]

I want to end up with

[ Card "Skwortul" Wet False [Move "Squirt" 20]
, Card "Scorchander" Hot False [Move "Scorch" 20]
, Card "Seedasaur" Leafy False [Move "Allergize" 20]
, Card "Kapichu" Spark False [Move "Poke" 10 , Move "Zap" 30]
, Card "Elecdude" Spark False [Move "Asplode" 50]
, Card "Garydose" Wet True [Move "Gary's move" 40]
, Card "Moisteon" Wet False [Move "Soggy" 3]
, Card "Grasseon" Leafy False [Move "Leaf Cut" 30]
, Card "Spicyeon" Hot False [Move "Capsaicisize" 40]
, Card "Sparkeon" Spark True [Move "Shock" 40 , Move "Battery" 50]
]
  • Is it acceptable to use external commands (paste)? – D. Ben Knoble Jan 27 at 13:23
  • I thought that this would be and easy command where the block is yanked in visual block and then pasted at the end of the lines in some way. – William Rusnack Jan 27 at 16:29
  • I would prefer that it be universal across OS so that might make external commands a bit difficult. – William Rusnack Jan 27 at 16:31
  • it might be possible with visual block mode. I havent experimented yet. – D. Ben Knoble Jan 27 at 17:20
1

You could certainly do it with visual blocks, with a caveat. Visual blocks need to be rectangular, so by selecting blocks with Ctrl-V followed by the necessary motions and yanking and pasting, you actually end up with something looking like this:

[ Card "Skwortul"    Wet False   [Move "Squirt" 20]                    
, Card "Scorchander" Hot False   [Move "Scorch" 20]                    
, Card "Seedasaur"   Leafy False [Move "Allergize" 20]                 
, Card "Kapichu"     Spark False [Move "Poke" 10 , Move "Zap" 30]      
, Card "Elecdude"    Spark False [Move "Asplode" 50]                   
, Card "Garydose"    Wet True    [Move "Gary's move" 40]               
, Card "Moisteon"    Wet False   [Move "Soggy" 3]                      
, Card "Grasseon"    Leafy False [Move "Leaf Cut" 30]                  
, Card "Spicyeon"    Hot False   [Move "Capsaicisize" 40]              
, Card "Sparkeon"    Spark True  [Move "Shock" 40 , Move "Battery" 50] 
]

which differs from what you requested in your question in that it has extra spaces. If the spaces are not significant for your application, you are done. (You might even argue that it looks better because the columns are aligned!) But if you want to remove the spaces, you could do it with :%s/ */ /g. This works as long as there are no repeated spaces that you do want to keep (your example appears to have none).

| improve this answer | |
1

It might be best to do it by macro. Over the first relevant line(in the block) do qa/#block<CR>+"bd$/#block<CR>+"cd$<c-o><c-o>"bp"cp+q

I might interpret this later. Hopefully, I am not wrong. (<CR> is to press enter, you might just want to type it once)

then do @a for all the relevant lines (a number indicates the number of times to execute )

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.