Friday, April 20, 2012

Recording A Script

I'm recording a script by doing

vim -w thescript.vim examplefile.txt

'man vim' says all characters are recorded until I exit vim, so, the last characters in thescript.vim end up being 'ZZ', because that's how I exit vim. Then, I want to add more operations to the script:

vim -w thescript.vim examplefile.txt

Now, thescript.vim ends up having my original 'ZZ' in there, along with my last 'ZZ' characters. Of course, when I come to source thescript.vim (with -s), only the commands that were performed in my first recording are performed, because they included 'ZZ', and vim exits the file I'm operating on. To work around this, I must edit thescript.vim and remove all but the last 'ZZ' characters.

I'm thinking there must be a way to tell vim to stop recording, which doesn't exit the file, therefore not putting the exit command ('ZZ') into thescript.vim. Something like this:

vim -w thescript.vim examplefile.txt
:%s/e/E/g " Or whatever my intended operation is
:stoprecording
ZZ
vim -w thescript.vim examplefile.txt
:%s/emacs/vim/g " Some other things I wanted to record
ZZ

Then, I could just

vim -s thescript.vim list.txt of.txt files.txt

instead of having to edit thescript.vim and remove exit commands.

--

.

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments: