简体   繁体   English

VIM获得E488尾随字符

[英]VIM get E488 Trailing characters

I try to add author and some other information using F4 . 我尝试使用F4添加作者和其他一些信息。

but when i open *.c or other files,(not *.sh),and push F4 ,it will display E488 Trailing characters. 但是当我打开* .c或其他文件(不是* .sh)并按F4时 ,它将显示E488尾随字符。

Also, when try to update the information, it meets E20 Mark not set. 另外,当尝试更新信息时,它会遇到未设置的E20标记。

And more question, when i try to using let suff = expand("%:e") to get java filename extension, then if suff == "java" and find that suff doesn't equal to "java", why? 还有更多问题,当我尝试使用let suff = expand("%:e")来获取Java文件扩展名时, if suff == "java"并发现该suff不等于“ java”,为什么?

This is my vim configure: 这是我的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

Remove the trailing ; 删除尾随; from this line: 从这一行:

call append(13,"");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM