编辑器设置:
- syntax on 语法高亮
- set number 显示行号
- set autoindent set cindent 自动缩进
- 自动加入文件头:
autocmd BufNewFile .py,.cpp,.sh,.java exec ":call SetTitle()"
func SetTitle()
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:www.t4x.org")
call append(line(".")+3, "# Contact:root#t4x.org")
call append(line(".")+4, "")
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 python")
call append(line("."), "# Author: Byrd")
call append(line(".")+1, "# Created Time: ".strftime("%c"))
call append(line(".")+2, "")
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
网友评论