vimscript: 为什么 '\S*\%>66c.*/\=substitute...'=~'\a\+' return true

vimscript: why does '\S*\%>66c.*/\=substitute...'=~'\a\+' return true

这是一个映射

map <silent> <2-LeftMouse> lB"gyE  
:if @g=~'ss\d\d\d\.png'  
  :call writefile([@g], "/home/g/xv.vss", "a")  
:elseif @g=~'http'  
  :call writefile([@g], "/home/g/dil.lo", "a")  
:elseif @g=~'_\d\+'  
  :let @/='^'.@g.'$'  
  :norm nzz  
:elseif @g=~'\a\+'  
  :vim /^\cg/ /mnt/1/dict/webster/all.txt  
:else  
  :norm 0y$:@"  
:endif  

这里是“g”的内容

\S*\%>66c.*/\=substitute(submatch(0),'

这是映射时产生的消息 运行

E303: Unable to open swap file for "=substitute(submatch(0),'/", recovery impossible  
Cannot open file "=substitute(submatch(0),'/"  
"all.txt" 530590 lines --0%--  

显然 vim 认为 "g 的内容等同于 \a\+ 因为它正式打开 all.txt 并试图在其中找到匹配项(韦氏词典) @g 并且通往该文件的唯一途径是通过上述测试。

谁能向我解释为什么这样做,或者其他解释?

=~ 检查模式是否匹配。它不会为您添加锚点,因此如果字符串的任何部分匹配,则该字符串算作匹配。

如果您只想接受您想要使用的字母字符 '^\a\+$' 而不是 \a\+