vim 配置 ~/.vimrc

" 显示行号

set number

" 历史纪录

set history=1000

" 输入的命令显示出来,看的清楚些

set showcmd

" 启动显示状态行1,总是显示状态行2

set laststatus=2

" 语法高亮显示

syntax on

set fileencodings=utf-8,gb2312,gbk,cp936,latin-1

set fileencoding=utf-8

set termencoding=utf-8

set fileformat=unix

set encoding=utf-8

" 配色方案

colorscheme desert

" 指定配色方案是256色

set t_Co=256

" 用空格代替tab

set expandtab

" 设置显示制表符的空格字符个数,改进tab缩进值,默认为8,现改为4

set tabstop=4

" 设定自动缩进为4个字符,程序中自动缩进所使用的空白长度

set shiftwidth=4

" 设置帮助文件为中文(需要安装vimcdoc文档)

set helplang=cn

" 显示匹配的括号

set showmatch

" delete

set backspace=2

" Uncomment the following to have Vim jump to the last position when

" reopening a file

if has("autocmd")

  au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif

endif

 

" 显示行号
set number
" 历史纪录
set history=1000
" 输入的命令显示出来,看的清楚些
set showcmd
" 启动显示状态行1,总是显示状态行2
set laststatus=2
" 语法高亮显示
syntax on
set fileencodings=utf-8,gb2312,gbk,cp936,latin-1
set fileencoding=utf-8
set termencoding=utf-8
set fileformat=unix
set encoding=utf-8
" 配色方案
colorscheme desert
" 指定配色方案是256色
set t_Co=256

" 用空格代替tab
set expandtab

" 设置显示制表符的空格字符个数,改进tab缩进值,默认为8,现改为4
set tabstop=4

" 设定自动缩进为4个字符,程序中自动缩进所使用的空白长度
set shiftwidth=4

" 设置帮助文件为中文(需要安装vimcdoc文档)
set helplang=cn

" 显示匹配的括号
set showmatch

" delete
set backspace=2

" Uncomment the following to have Vim jump to the last position when       
" reopening a file                                                         
if has("autocmd")                                                          
  au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif                                                        
endif

autocmd BufNewFile *.go,*.c,*.cpp,*.sh,*.py,*.java exec ":call SetTitle()"
"定义函数SetTitle,自动插入文件头
func SetTitle()
        "如果文件类型为.c或者.cpp文件
        if (&filetype == 'c' || &filetype == 'cpp' || &filetype == 'go')
                call setline(1, "/*************************************************************************")  
                call setline(2, "\ @Author: xihuaxiao")  
                call setline(3, "\ @Created Time : ".strftime("%c"))  
                call setline(4, "\ @File Name: ".expand("%"))  
                call setline(5, "\ @Description:")  
                call setline(6, " ************************************************************************/")  
                call setline(7,"")  
        endif
        "如果文件类型为.sh文件
        if &filetype == 'shell'  
                call setline(1, "\#!/bin/sh")
                call setline(2, "\# Author: xihuaxiao")
                call setline(3, "\# Created Time : ".strftime("%c"))
                call setline(4, "\# File Name: ".expand("%"))
                call setline(5, "\# Description:")
                call setline(6,"")
        endif
        "如果文件类型为.py文件
        if &filetype == 'python'
                call setline(1, "\#!/usr/bin/env python")
                call setline(2, "\# -*- coding=utf8 -*-")
                call setline(3, "\"\"\"")
                call setline(4, "\# Author: xihuaxiao")
                call setline(5, "\# Created Time : ".strftime("%c"))
                call setline(6, "\# File Name: ".expand("%"))
                call setline(7, "\# Description:")
                call setline(8, "\"\"\"")
                call setline(9,"")
        endif
        "如果文件类型为.java文件
        if &filetype == 'java'  
                call setline(1, "//coding=utf8")  
                call setline(2, "/**")  
                call setline(3, "\ *\ @Author: xihuaxiao")  
                call setline(4, "\ *\ @Created Time : ".strftime("%c"))  
                call setline(5, "\ *\ @File Name: ".expand("%"))  
                call setline(6, "\ *\ @Description:")  
                call setline(7, "\ */")  
                call setline(8,"")  
        endif
endfunc
" 自动将光标移动到文件末尾
autocmd BufNewfile * normal G

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值