Reputation: 3555
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.
Upvotes: 9
Views: 22862
Reputation: 18730
If you're seeing E20: Mark not set
by accident, you can proceed with the command you were trying to run.
E.g. hit i
to enter edit mode and the message will go away.
I was trying to type a backtick ` followed by letters, thinking I was in edit mode, which happens to be the way you jump to a mark (see Using marks).
Upvotes: 4
Reputation: 195099
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
?
Upvotes: 14