Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

An "E20: Mark not set" when try to update info in VIM

Tags:

vim

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.

like image 553
Sheng Avatar asked Dec 16 '22 12:12

Sheng


1 Answers

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?

  • This error msg will clear your message (echoed in your function). That's why you cannot see it.
  • The function worked because it happened before your "typo"
like image 82
Kent Avatar answered Dec 21 '22 09:12

Kent