Recording A Script

8 views
Skip to first unread message

Paul

unread,
Apr 20, 2012, 6:42:31 AM4/20/12
to vim...@googlegroups.com
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.

--

.

Reply all
Reply to author
Forward
0 new messages