Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Combine multiple text files in Vim

Tags:

vim

I have a fairly simple question that I can't find an answer to, and can't seem to make work for me.

I need to append multiple text files (all within the same directory) within Vim. The reason I need to do it within Vim is that I'm running windows and don't have access to *nix utilities.

All the files have a pattern in their name (ex1.sql, ex2.sql, ex3.sql).

All I need to do is grad the text from them (in the order they are in the directory), and append them into a new blank file.

I've made the argument list

:args ex*.sql

And want to perform a command on all the args into the a register.

:argdo gg"AyG

It says that the lines were copied from each of the files.

When I go to paste the register into a new file, however, nothing prints.

:"ap

So I check the register:

:reg

the a register is filled with gibberish (^]Jyecw?).

Is there a better way of going about this? Why is it saying that it's copying into a register, but is in fact putting in a bunch of strange characters?

like image 418
svh160 Avatar asked Nov 21 '25 19:11

svh160


1 Answers

argdo executes an ex-mode command in each file of the argument list. What you want to do with gg"AyG is execute a normal command. Try:

:argdo normal gg"AyG
like image 91
Daan Bakker Avatar answered Nov 24 '25 10:11

Daan Bakker



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!