In my vimrc file I am trying to write a function that take in two lines numbers as arguments and then comments out all the lines in that range. I am using a substitute for the start of the line '^' and replacing it with '#' which works fine when I call from outside a function. For the function I have this so far:
function Comment(line1, line2)
a:line1,a:line2s/^/#/g
endfunction
This is not working though and I am getting an error when I try to start Vim saying 'Missing :endfunction'