gpt4 book ai didi

VIM 获取 E488 尾随字符

转载 作者:行者123 更新时间:2023-12-02 22:40:57 25 4
gpt4 key购买 nike

我尝试使用 F4 添加作者和一些其他信息。

但是当我打开*.c 或其他文件(不是*.sh),然后按F4 时,它会显示E488 Trailing characters.

另外,尝试更新信息时遇到E20 Mark not set。

还有更多问题,当我尝试使用让 suff = expand("%:e") 获取 java 文件扩展名,然后 if suff == "java" 发现 suff 不等于 "java “, 为什么?

这是我的 vim 配置:

" Add Author Information
map <F4> :call TitleDet()<CR>'s

function AddTitle()
call append(0,"/*========================================")
call append(1,"#")
call append(2,"# Author: xxx ")
call append(3,"#")
call append(4,"# Email: xxx@gmail.com")
call append(5,"#")
call append(6,"# Last modified: ".strftime("%Y-%m-%d %H:%M"))
call append(7,"#")
call append(8,"# Filename: ".expand("%:t"))
call append(9,"#")
call append(10,"# Description: ")
call append(11,"#")
call append(12,"======================================*/")
call append(13,"");
echohl WarningMsg | echo "Successful in adding the copyright." | echohl None
endfunction


function AddShellTitle()
call append(0,"#=========================")
call append(1,"#")
call append(2,"# Author: xxx")
call append(3,"#")
call append(4,"# Email: xxx")
call append(5,"#")
call append(6,"# Last modified: ".strftime("%Y-%m-%d %H:%M"))
call append(7,"#")
call append(8,"# Filename: ".expand("%:t"))
call append(9,"#")
call append(10,"# Description: ")
call append(11,"#")
call append(12,"#========================")
echohl WarningMsg | echo "Successful in adding the copyright." | echohl None
endfunction

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 copy right." | echohl None
endfunction


function UpdateShellTitle()
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 copy right." | echohl None
endfunction

function TitleDet()
let n=1
let suff = expand("%:e")
while n < 10
let line = getline(n)
if suff != "sh"
if line =~ '^\#\s*\S*Last\smodified:\S*.*$'
call UpdateTitle()
return
endif
else
if line =~ '^\#\s*\S*Last\smodified:\S*.*$'
call UpdateShellTitle()
return
endif
endif
let n = n + 1
endwhile
if suff != "sh"
call AddTitle()
else
call AddShellTitle()
endif
endfunction

最佳答案

从这一行中删除结尾的 ;:

call append(13,"");

关于VIM 获取 E488 尾随字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10799817/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com