更多vim请参考:https://github.com/ma6174/vim
通过:set paste+i粘贴到~/.vimrc
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
""定义函数SetTitle,自动插入文件头 autocmd BufNewFile *.py,*.cpp,*.sh,*.java exec ":call SetTitle()" func SetTitle() "如果文件类型为.sh文件 if &filetype == 'sh' call setline(1,"\#!/bin/bash") call append(line("."), "# Author:Byrd") call append(line(".")+1, "# Version:0.1") call append(line(".")+2, "# Site:note.t4x.org") call append(line(".")+3, "# Contact:root#t4x.org") call append(line(".")+4, "export LANG=en_US.UTF-8") call append(line(".")+5, "") elseif &filetype == 'cpp' call setline(1,"// File Name: ".expand("%")) call append(line("."), "// Author: Byrd") call append(line(".")+1, "// Created Time: ".strftime("%c")) call append(line(".")+2, "") call append(line(".")+3, "#include<iostream>") call append(line(".")+4, "#include<string>") call append(line(".")+5, "#include<algorithm>") call append(line(".")+6, "#include<cstdlib>") call append(line(".")+7, "using namespace std;") call append(line(".")+8, "int main(){") call append(line(".")+9, "") call append(line(".")+10, " return 0") call append(line(".")+11,"}") elseif &filetype == 'python' call setline(1,"\#!/usr/bin/env python3") call append(line("."), "# -*- coding:utf-8 -*-") call append(line(".")+1, "# Author: Byrd") call append(line(".")+2, "# Created Time: ".strftime("%c")) call append(line(".")+3, "") else call setline(1,"/*") call append(line("."), "* Author: Byrd") call append(line(".")+1, "* Created Time: ".strftime("%c")) call append(line(".")+2, "*/") call append(line(".")+3, "") endif endfunc "新建文件后,自动定位到文件末尾 autocmd BufNewFile * normal G "ts是tabstop的缩写,设TAB宽4个空格 set ts=4 set expandtab |
参考:https://github.com/ma6174/vim
参考:http://www.cnblogs.com/fangtest/p/3764252.html
参考:http://blog.csdn.net/yuanlu837/article/details/7862875
参考:http://www.cppblog.com/hdqqq/archive/2010/12/07/135719.html SourceByrd's Weblog-https://note.t4x.org/system/define-byrd-sh/
申明:除非注明Byrd's Blog内容均为原创,未经许可禁止转载!详情请阅读版权申明!