2

I want to replace old by new string by using call:Rep(new,old) . So my pseudo code is like this...

I am new to vimscript , I don't know how to do it.

function! Rep(old,new)
   !sed -i.bak 's/#{old}/#{new}/g' *
endfunction

Do you have any idea? Thanks.

1 Answer 1

3

Change your function to

function! Rep(old,new)
   exe "!sed -i.bak 's/".a:old."/".a:new."/g' *"
endfunction

then use :call Rep(old,new). You can also create a command for it.

command! -nargs=+ Rep call Rep(<args>)

so that you can do :Rep old new.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.