vim自定义功能

在.vimrc中自定义功能,或者在别的文件中自定义,在.vimrc中source,功能名一定要用大写。

function Test()
  ...
endfunction

然后在命令行中,:call test()运行
也可以自定义为map <leader>te :call test()<cr>
示例:

function Addtitle()
  let username = system('whoami')
  call append(1,"Project     :")
  call append(2,"Filename  :".expand("%:t"))
  call append(3,"author      :".username)
  call append(4,"time         :".strftime("%Y-%m-%d %H:%M"))
endfunction
posted @ 2025-05-14 15:20  心比天高xzh  阅读(15)  评论(0)    收藏  举报