"2015年 10月 15日 星期四 15:04:20 EDT
set shiftwidth=8
set tabstop=8
set autoindent
"2015.2.1 creat Makefile Template
autocmd BufNewFile Makefile 0r /home/dd/Template/Makefile
"2015.2.1 光标移动到buffer的顶部和底部式保持3行距离
set scrolloff=3
"2015.2.1 creat file templates
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"新建.c,.h,.sh,.java文件,自动插入文件头
autocmd BufNewFile *.cpp,*.cc,*.[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, "\# Function: ")
call append(line(".")+2, "\# Author: SongDong")
call append(line(".")+3, "\# mail: songdongjob@163.com")
call append(line(".")+4, "\# Created Time: ".strftime("%c"))
call append(line(".")+5, "\#########################################################################")
call append(line(".")+6, "\#!/bin/bash")
call append(line(".")+7, "")
else
call setline(1, "/*************************************************************************")
call append(line("."), " > File Name: ".expand("%"))
call append(line(".")+1, " > Function: ")
call append(line(".")+2, " > Author: SongDong")
call append(line(".")+3, " > Mail: songdongjob@163.com")
call append(line(".")+4, " > Created Time: ".strftime("%c"))
call append(line(".")+5, " > Version: v1.0")
call append(line(".")+6, " ************************************************************************/")
call append(line(".")+7, "")
endif
if &filetype == 'cpp' || 'cc'
call append(line(".")+8, "#include <iostream>")
call append(line(".")+9, "using namespace std;")
call append(line(".")+10, " ")
call append(line(".")+11, "int main(int argc, char *argv[])")
call append(line(".")+12, "{")
call append(line(".")+13, " return 0;")
call append(line(".")+14, "}")
endif
if &filetype == 'c'
call append(line(".")+8, "#include <stdio.h>")
call append(line(".")+9, "")
call append(line(".")+10, "int main(int argc, char *argv[])")
call append(line(".")+11, "{")
call append(line(".")+12, " return 0;")
call append(line(".")+13, "}")
endif
" if &filetype == 'java'
" call append(line(".")+6,"public class ".expand("%"))
" call append(line(".")+7,"")
" endif
"新建文件后,自动定位到文件末尾
autocmd BufNewFile * normal G
endfunc
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"凸显当前行
set cursorline
set shiftwidth=8
set tabstop=8
set autoindent
"2015.2.1 creat Makefile Template
autocmd BufNewFile Makefile 0r /home/dd/Template/Makefile
"2015.2.1 光标移动到buffer的顶部和底部式保持3行距离
set scrolloff=3
"2015.2.1 creat file templates
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"新建.c,.h,.sh,.java文件,自动插入文件头
autocmd BufNewFile *.cpp,*.cc,*.[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, "\# Function: ")
call append(line(".")+2, "\# Author: SongDong")
call append(line(".")+3, "\# mail: songdongjob@163.com")
call append(line(".")+4, "\# Created Time: ".strftime("%c"))
call append(line(".")+5, "\#########################################################################")
call append(line(".")+6, "\#!/bin/bash")
call append(line(".")+7, "")
else
call setline(1, "/*************************************************************************")
call append(line("."), " > File Name: ".expand("%"))
call append(line(".")+1, " > Function: ")
call append(line(".")+2, " > Author: SongDong")
call append(line(".")+3, " > Mail: songdongjob@163.com")
call append(line(".")+4, " > Created Time: ".strftime("%c"))
call append(line(".")+5, " > Version: v1.0")
call append(line(".")+6, " ************************************************************************/")
call append(line(".")+7, "")
endif
if &filetype == 'cpp' || 'cc'
call append(line(".")+8, "#include <iostream>")
call append(line(".")+9, "using namespace std;")
call append(line(".")+10, " ")
call append(line(".")+11, "int main(int argc, char *argv[])")
call append(line(".")+12, "{")
call append(line(".")+13, " return 0;")
call append(line(".")+14, "}")
endif
if &filetype == 'c'
call append(line(".")+8, "#include <stdio.h>")
call append(line(".")+9, "")
call append(line(".")+10, "int main(int argc, char *argv[])")
call append(line(".")+11, "{")
call append(line(".")+12, " return 0;")
call append(line(".")+13, "}")
endif
" if &filetype == 'java'
" call append(line(".")+6,"public class ".expand("%"))
" call append(line(".")+7,"")
" endif
"新建文件后,自动定位到文件末尾
autocmd BufNewFile * normal G
endfunc
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"凸显当前行
set cursorline
"set magic
vim中Ctrl+s 锁死屏幕,Ctrl+q解锁,