I met a trouble with updating the info in VIM with function. My code is as following:
map <F4> :call UpdateTitle()<cr>'s
"Update the latest modification time and filename
function UpdateTitle()
normal m'
execute '/# *Last modified:/s@:.*$@\=strftime(": %Y-%m-%d %H:%M")@'
normal ''
normal mk
execute '/# *Filename:/s@:.*$@\=": ".expand("%:t")@'
execute "noh"
normal 'k
echohl WarningMsg | echo "Successful in updating the copyright." | echohl None
endfunction
When I press F4 in VIM, it DOES work. BUT it always show an error message as E20: Mark not set
. I thought the error happens at the last two line. But I cannot find out a solution.
I tried echoerr
. It works, but not what I what.
I tried echomsg
and echo
alone. But it does not work. No message output. But a error message shows as E20: Mark not set
.
Furthermore, even if I delete the whole echo line. The same error shows again.
VIM version is 7.0.237.
E20: Mark not set
Usually this means you are trying to jump to a non-existant mark.
Take a look at your map:
map <F4> :call UpdateTitle()<cr>'s
What is the 's
at the end? Do you have mark s
?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With