A. S. Budden wrote: > 2009/3/16 Horvath Adam <[email protected]>: >> Dear List Members! >> >> I need to correct sql dump files: >> >> Question 1: >> >> I like to this with vimscript: >> :%s/xxx/yyy/g >> For all line in buffer and all occurencies in line >> >> How can it be done wiht script? > > There may be better ways, but here's one possibility: > > for l in range(line('$')) > call setline(l, substitute(getline('l', 'xxx', 'yyy', '') > endfor
Ex commands are usable as-is in scripts. Just remove the leading colon: %s/xxx/yyy/g it doesn't get much easier to translate ;-) Note: it does move the cursor to the line where the last substitution was performed, so you may want to save/restore your line position if you care: mark a %s/xxx/yyy/g 'a -tim --~--~---------~--~----~------------~-------~--~----~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~----------~----~----~----~------~----~------~--~---
