svh160
svh160

Reputation: 77

Combine multiple text files in 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?

Upvotes: 3

Views: 5483

Answers (1)

Daan Bakker
Daan Bakker

Reputation: 6332

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

Upvotes: 6

Related Questions