in vim, how to append/insert text with argdo?

append, insert, vi, vim

Solution

I'm unclear where you're trying to insert the text in the buffer. If you want it after the current line:

:argdo exe 'normal osometext'

Inserting text with linebreaks in it:

:argdo exe "normal osometext\<CR>anewline"

Problem

There's the ":a" command, but that's multi-line, and argdo asks you for the text again for each file. The docs mention the global command (g/pat/command) that will use an alternative version of ":a" that is terminated by a newline instead of by "." on a line (you can include newlines by escaping them with "\"). But I couldn't get this to work. The only way I've seen is to first yank the text-to-be-added into a named register, then use: ``` :argdo put x " where x is the register ``` I'm hoping for something like ``` :argdo append myTextHere ```

Original source