[vox-tech] vim question

Peter Jay Salzman vox-tech@lists.lugod.org
Thu, 1 Aug 2002 17:06:23 -0700


hola,

one of my students asked me a question i couldn't answer.

at the bottom of the file, he has:

-> :!top
-> :!nice -n10 planetary % &
-> :w

he was playing around with vim and came up with the following macros:

> map <F12> mzG3l"zDp'z@z<CR>
> map <F11> mzGk3l"zDp'z@z<CR>
> map <F10> mzGkk3l"zDp'z@z<CR>
> map <F9>  mzGkkk3l"zDp'z@z<CR>

so <F9> writes the file.  it does this by skipping over "-> ", putting
the command in the z buffer by deleting to the end of the line and then
executing the z buffer.  he also rigs things up so that the cursor is
returned to its original position (his ' should actually be a `).

his question was: can you do a search and replace on a buffer?

in other words, i guess it would be something like:

map <F1> mzG"zyy `z@z<CR>
                ^
                | this is where we'd get rid of "-> " in the z buffer

does anybody know how to do this?

before anyone asks, the goal isn't mapping a single key to save.  it's
just to learn how to do a search/replace on a vim buffer.

btw, this kid is a sophmore in highschool.  he's going to be one awesome
vim user.  i'm thoroughly impressed by him.  his name is marcello and
he's hoping to make it to the next lugod meeting.

pete