I asked a question a few days ago in the Linux/Unix SE about how to copy a block of text from one file to another in a way that I could use for a script of many similar files. I thought I came up with a pretty simple solution, but I have run into a snag: my code seems to work only the first time I execute it. Any time after it won't seem to do. For an example, here is the gist of my code:
ex -c "normal! 1gg19|^V48gg59|y" -cq file1
This goes into file1, creates a visual block from the point (1,19) to (48,59) in the file, yanks it, and then closes the file.
ex -c "normal! 9gg21|p" -cwq file2
This goes into file2, moves the cursor to the point (9,21), pastes, and then closes the file.
If I run this once, it seems to work fine (minus any hiccups I cause by messing up the line numbers). But then if I run it again, neither line of code (in particular the first line) does anything. I have tried performing what each line of code is supposed to do in just plain vi, but then the other line will do nothing.
One particular issue I've noticed is if I run the first line and then try to manually perform the second, I get an error message "E353: Nothing in register"
vim ex -c"...
or are you running it from vim,:ex -c "...
or is it in a vimrcex -c"...
?ex
confused me for a bit, but I'm assuming thatex
is just aliased tovim
on your system? (That's standard for Linux machines these days right?)