Reputation: 33
It have this code:
autocmd BufWritePre,FileWritePre *vimrc call LastMod()
fun LastMod()
let l = min([line('$'), 8])
exe "1," . l . "g/Modified Times:/s/\d\+/\=submatch(0) + 1/"
endfun
When I run it as a cmd, it works:
1,8g/Modified Times:/s/\d\+/\=submatch(0) + 1/
But doesn't work in the function. Why?
Upvotes: 2
Views: 43
Reputation: 32976
You're using double quotes instead of simple quotes. All your backslashes need to be doubled. Or better yet, use single quotes.
PS: it would have been better to describe what you were observing. Luckily, your mistake is a recurring one.
Upvotes: 3