.vimrc
作者:互联网
"color asmanian2 " 设置背景主题
"syntax on " 语法高亮
"""""新文件标题""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"新建.c,.h,.sh,.java文件,自动插入文件头
autocmd BufNewFile *.cpp,*.[ch],*.sh,*.java exec ":call SetTitle()"
""定义函数SetTitle,自动插入文件头
func SetTitle()
"如果文件类型为.sh文件
if &filetype == 'sh'
call setline(1,"\#########################################################################")
call append(line("."), "\# File Name: ".expand("%"))
call append(line(".")+1, "\# Author: MuRKuo")
call append(line(".")+2, "\# mail: 1442121990@qq.com")
call append(line(".")+3, "\# Created Time: ".strftime("%c"))
call append(line(".")+4, "\#########################################################################")
call append(line(".")+5, "\#!/bin/bash")
call append(line(".")+6, "")
else
call setline(1, "/*************************************************************************")
call append(line("."), " > File Name: ".expand("%"))
call append(line(".")+1, " > Author: MuRKuo")
call append(line(".")+2, " > Mail: 1442121990@qq.com ")
call append(line(".")+3, " > Created Time: ".strftime("%c"))
call append(line(".")+4, " ************************************************************************/")
call append(line(".")+5, "")
endif
if &filetype == 'cpp'
call append(line(".")+6, "#include<iostream>")
call append(line(".")+7, "using namespace std;")
call append(line(".")+8, "")
endif
if &filetype == 'py'
call append(line(".")+6, "#!/usr/bin/python")
call append(line(".")+8, "")
endif
if &filetype == 'c'
call append(line(".")+6, "#include<stdio.h>")
call append(line(".")+7, "")
endif
"新建文件后,自动定位到文件末尾
autocmd BufNewFile * normal G
endfunc
" 设置当文件被改动时自动载入
set autoread
"代码补全
set completeopt=preview,menu
" 显示行号
set number
"打开文件类型检测, 加了这句才可以用智能补全
set completeopt=longest,menu
" Pydiction plus
filetype plugin on
let g:pydiction_location = '~/.vim/tools/pydiction/complete-dict'
let g:pydiction_menu_height = 3
autocmd BufNewFile *.py exec ":call AddTitleForPY()"
function AddTitleForPY()
call append(0,"#!/usr/bin/python")
call append(1,"-*- coding: utf-8 -*-")
call append(2,"'''")
call append(3,"Author : MuRKuo")
call append(4,"Email : 1442121990@qq.com")
call append(5,"Create time : ".strftime("%Y-%m-%d %H:%M"))
call append(6,"Filename : ".expand("%:t"))
call append(7,"'''")
endfunction
标签:文件,set,vimrc,filetype,call,line,append 来源: https://www.cnblogs.com/murkuo/p/15367744.html