を使用して、作成者やその他の情報を追加しようとしていF4ます。
しかし、*。cまたは他のファイル(* .shではない)を開いて押すF4と、E488末尾の文字が表示されます。
また、情報を更新しようとすると、E20マークが設定されていません。
さらに質問が
あります。Javalet suff = expand("%:e")
ファイル名拡張子を取得するために使用しようとする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