Linux设置vim新建文件添加注释

Linux 上用vim做开发时,默认添加新建文件之后的一些备注,注释等设置;

在~/.vimrc 中添加如下代码。

autocmd BufNewFile *.py call SetNote()
  8     func SetNote()
  9             call setline(1, "# coding: utf-8")
 10             call append(line("."), "# Author: wc")
 11             call append(line("."), "# Email: [email protected]")
 12             call append(line("."), "# Date: ".strftime("%Y年%m月%d日"))
 13     endfunc
 14     autocmd BufNewFile * normal G

 注:最后一行把光标定位到末尾

你可能感兴趣的:(Linux)