新建文件,自动加入文件头

修改文件,保存时,自动更新修改时间字段

自动匹配括号,引号等

vimrc文件如下

 "==========================================
"General
"========================================== " history存储长度。
set history=
set encoding=utf-
set fileencodings=ucs-bom,utf-,cp936
set fileencoding=gb2312
set termencoding=utf- "检测文件类型
filetype on
" 针对不同的文件类型采用不同的缩进格式
filetype indent on
"允许插件
filetype plugin on
"启动自动补全
filetype plugin indent on " 非兼容vi模式。去掉讨厌的有关vi一致性模式,避免以前版本的一些bug和局限
set nocompatible
set autoread " 文件修改之后自动载入。 " 取消备份。
" Turn backup off, since most stuff is in SVN, git et.c anyway...
set nobackup
set nowb
set noswapfile " No annoying sound on errors
" 去掉输入错误的提示声音
set noerrorbells
set novisualbell
set t_vb=
set tm= "==========================================
" show and format
"==========================================
"显示行号:
set number
set nowrap " 取消换行。
""为方便复制,用<F2>开启/关闭行号显示:
nnoremap <F2> :set nonumber!<CR>:set foldcolumn=<CR> "括号配对情况
set showmatch
" How many tenths of a second to blink when matching brackets
set mat= "设置文内智能搜索提示
" 高亮search命中的文本。
set hlsearch
" 搜索时忽略大小写
set ignorecase
" 随着键入即时搜索
set incsearch
" 有一个或以上大写字母时仍大小写敏感
set smartcase " 代码折叠
" set foldenable
" 折叠方法
" manual 手工折叠
" indent 使用缩进表示折叠
" expr 使用表达式定义折叠
" syntax 使用语法定义折叠
" diff 对没有更改的文本进行折叠
" marker 使用标记进行折叠, 默认标记是 {{{ 和 }}}
" set foldmethod=syntax
" 在左侧显示折叠的层次
" set foldcolumn=4 set tabstop= " 设置Tab键的宽度 [等同的空格个数]
set shiftwidth=
set expandtab " 将Tab自动转化成空格 [需要输入真正的Tab键时,使用 Ctrl+V + Tab]
" 按退格键时可以一次删掉 4 个空格
set softtabstop= set ai "Auto indent
set si "Smart indent "==========================================
" status
"==========================================
"显示当前的行号列号:
set ruler
""在状态栏显示正在输入的命令
set showcmd " Set 7 lines to the cursor - when moving vertically using j/k 上下滚动,始终在中间
set so= "set cursorline " 突出显示当前行 " 命令行(在状态行下)的高度,默认为1,这里是2
" set cmdheight=2
set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [POS=%l,%v][%p%%]\ %{strftime(\"%d/%m/%y\ -\ %H:%M\")}
" Always show the status line
set laststatus= "==========================================
"colors and fonts
"==========================================
"开启语法高亮
syntax enable
syntax on "配色方案 三种,选一个
"colorscheme darkblue " 深蓝色配色方案。 "colorscheme desert " 经典配色方案。
"set background=dark " Set extra options when running in GUI mode
if has("gui_running")
set guioptions-=T
set guioptions+=e
set t_Co=
set guitablabel=%M\ %t
endif
"set guifont=Monaco:h20 " 字体 && 字号 "==========================================
" file encode
"========================================== " Use Unix as the standard file type
set ffs=unix,dos,mac " 如遇Unicode值大于255的文本,不必等到空格再折行。
set formatoptions+=m
" 合并两行中文时,不在中间加空格:
set formatoptions+=B "==========================================
"others
"========================================== " 自动完成
set completeopt=longest,menu
" 增强模式中的命令行自动完成操作
set wildmenu
" Ignore compiled files
set wildignore=*.o,*~,*.pyc " Python 文件的一般设置,比如不要 tab 等
autocmd FileType python set tabstop= shiftwidth= expandtab
"自动补全配置
autocmd FileType python set omnifunc=pythoncomplete#Complete " Return to last edit position when opening files (You want this!)
autocmd BufReadPost *
\ if line("'\"") > && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif " A buffer becomes hidden when it is abandoned
"set hid " For regular expressions turn magic on
set magic " Configure backspace so it acts as it should act
set backspace=eol,start,indent
set whichwrap+=<,>,h,l "新建.c,.h,.sh,.Java文件,自动插入文件头
autocmd BufNewFile *.cpp,*.hpp,*.cc,*.[ch],*.sh,*.Java exec ":call SetTitle()"
""定义函数SetTitle,自动插入文件头
func SetTitle()
if &filetype == 'sh'
call setline(,"\#########################################################################")
call append(line("."), "\# File Name: ".expand("%"))
call append(line(".")+, "\# Author: carbonyang@shuame.com")
call append(line(".")+, "\# Description: carbonyang@shuame.com")
call append(line(".")+, "\# Created Time: ".strftime("%c"))
call append(line(".")+, "\# Modified Time: ".strftime("%c"))
call append(line(".")+, "\#########################################################################")
call append(line(".")+, "")
call append(line(".")+, "")
call append(line(".")+, "")
call append(line(".")+, "\#!/bin/bash")
call append(line(".")+, "")
else
call setline(, "/*************************************************************************")
call append(line("."), "\ * File Name: ".expand("%"))
call append(line(".")+, "\ * Author: carbonyang@shuame.com")
call append(line(".")+, "\ * Created Time: ".strftime("%Y-%m-%d %H:%M:%S %Z"))
call append(line(".")+, "\ * Modified Time: ".strftime("%Y-%m-%d %H:%M:%S %Z"))
call append(line(".")+, "\ * Description: ")
call append(line(".")+, "\ * ┏┛ ┻━━━━━┛ ┻┓")
call append(line(".")+, "\ * ┃ ┃")
call append(line(".")+, "\ * ┃ ━ ┃")
call append(line(".")+, "\ * ┃ ┳┛ ┗┳ ┃")
call append(line(".")+, "\ * ┃ ┃")
call append(line(".")+, "\ * ┃ ┻ ┃")
call append(line(".")+, "\ * ┃ ┃")
call append(line(".")+, "\ * ┗━┓ ┏━━━┛")
call append(line(".")+, "\ * ┃ ┃ 神兽保佑")
call append(line(".")+, "\ * ┃ ┃ 代码无虫")
call append(line(".")+, "\ * ┃ ┗━━━━━━━━━┓")
call append(line(".")+, "\ * ┃ ┣┓")
call append(line(".")+, "\ * ┃ ┏┛")
call append(line(".")+, "\ * ┗━┓ ┓ ┏━━━┳ ┓ ┏━┛")
call append(line(".")+, "\ * ┃ ┫ ┫ ┃ ┫ ┫")
call append(line(".")+, "\ * ┗━┻━┛ ┗━┻━┛")
call append(line(".")+, "************************************************************************/")
call append(line(".")+, "")
call append(line(".")+, "")
call append(line(".")+, "")
endif
if &filetype == 'cpp'
call append(line(".")+, "#include<iostream>")
call append(line(".")+, "")
call append(line(".")+, "using namespace std;")
call append(line(".")+, "")
call append(line(".")+, "")
endif
if &filetype == 'c'
call append(line(".")+, "#include<stdio.h>")
call append(line(".")+, "")
call append(line(".")+, "")
endif
autocmd BufNewFile * normal G
endfunc let g:update_time_time_stamp_leader = 'Modified Time: '
let g:update_time_enable =
let g:update_time_time_format = '%Y-%m-%d %H:%M:%S %Z'
map <F4> gg: <Esc>O<Esc>: call SetTitle()<cr> <Esc>G " 括号自动补全
inoremap ( ()<Esc>i
inoremap [ []<Esc>i
inoremap { {<CR>}<Esc>O
autocmd Syntax html,vim inoremap < <lt>><Esc>i| inoremap > <c-r>=ClosePair('>')<CR>
inoremap ) <c-r>=ClosePair(')')<CR>
inoremap ] <c-r>=ClosePair(']')<CR>
inoremap } <c-r>=CloseBracket()<CR>
inoremap " <c-r>=QuoteDelim('"')<CR>
inoremap ' <c-r>=QuoteDelim("'")<CR> function ClosePair(char)
if getline('.')[col('.') - ] == a:char
return "\<Right>"
else
return a:char
endif
endf function CloseBracket()
if match(getline(line('.') + ), '\s*}') <
return "\<CR>}"
else
return "\<Esc>j0f}a"
endif
endf function QuoteDelim(char)
let line = getline('.')
let col = col('.')
if line[col - ] == "\\"
return a:char
elseif line[col - ] == a:char
return "\<Right>"
else
return a:char.a:char."\<Esc>i"
endif
endf

vimrc

自动更新修改时间需要用到插件update-time.vim

保存至.vim/plugin/即可自动加载

update-time代码:

 " File: update-time.vim
" Author: QianChenglong <qianchenglong2012@gmail.com>
" Create Time: 2013-12-04 19:36:21 CST
" Last Change: 2013-12-05 12:14:15 CST
" Description: Automatic update Last Change time " SECTION: Init"{{{
if exists("g:loaded_update_time")
finish
endif
let g:loaded_update_time = let s:save_cpo = &cpo
set cpo&vim
"}}}
" SECTION: Varible"{{{
if !exists('g:update_time_time_stamp_leader')
let s:time_stamp_leader = 'Last Change: '
else
let s:time_stamp_leader = g:update_time_time_stamp_leader
endif if !exists('g:update_time_time_format')
let s:time_format = '%Y-%m-%d %H:%M:%S %Z'
else
let s:time_format = g:update_time_time_format
endif if !exists("g:update_time_begin_line")
let s:begin_line =
else
let s:begin_line = g:update_time_begin_line
endif if !exists('g:update_time_end_line')
let s:end_line =
else
let s:end_line = g:update_time_end_line
endif if !exists('g:update_time_enable')
let s:update_time_enable =
else
let s:update_time_enable = g:update_time_enable
endif
"}}}
" SECTION: Funtions"{{{
fun Update_time_update()
if ! &modifiable
return
endif
if ! s:update_time_enable
return
endif
let bufmodified = getbufvar('%', '&mod')
if ! bufmodified
return
endif
let pos = line('.').' | normal! '.virtcol('.').'|'
exe s:begin_line
let line_num = search(s:time_stamp_leader, '', s:end_line)
if line_num >
let line = getline(line_num)
let line = substitute(line, s:time_stamp_leader . '\zs.*', strftime(s:time_format), '')
call setline(line_num, line)
endif
exe pos
endf
fun Update_time_toggle()
let s:update_time_enable = !s:update_time_enable
endf
"}}}
" SECTION: Autocommands"{{{
autocmd BufWritePre * call Update_time_update()
"}}}
" SECTION: Commands"{{{
com! -nargs= UpdateTimeToggle call Update_time_toggle()
"}}}
" SECTION: Clean up"{{{
let &cpo = s:save_cpo
unlet s:save_cpo
"}}}

update-time

vim配置vimrc的更多相关文章

  1. vim 配置.vimrc文件

    下面这个.vimrc文件是根据公司里的一个前辈配置的,这里记录下,方便以后使用.它的功能,其实跟网上很多.vimrc配置的相比,还是小儿科.我记录下来,主要还是因为自己已经习惯了这个工作环境跟快捷键. ...

  2. vim配置vimrc详解

    vimrc的存放位置: 系统 vimrc 文件: "$VIM/vimrc" 用户 vimrc 文件: "$HOME/.vimrc" 用户 exrc 文件: &q ...

  3. vim配置vimrc详解(转)

    vimrc的存放位置: 系统 vimrc 文件: "$VIM/vimrc" 用户 vimrc 文件: "$HOME/.vimrc" 用户 exrc 文件: &q ...

  4. 个人vim配置(.vimrc文件分享)

    syntax enable syntax on colorscheme desert set nu! set nowrap set nobackup set backspace= set tabsto ...

  5. vim配置go语法高亮

    操作系统 : CentOS7.3.1611_x64 go 版本 : go1.8.3 linux/amd64 vim版本 :version 7.4.160 vim配置go语言语法高亮的问题已经遇到过好几 ...

  6. ubuntu 配置vim(vimrc)

    打开终端:ctrl+alt+t 进入vim文件:cd /etc/vim 打开vimrc文件:sudo gedit vimrc 然后在行末if语句前加上下面的内容,"  这个符号为注释,后面内 ...

  7. linux 配置vim(vimrc)

    打开终端:ctrl+alt+t 进入vim文件:cd /etc/vim 打开vimrc文件:sudo gedit vimrc 然后在行末if语句前加上下面的内容,"  这个符号为注释,后面内 ...

  8. acm的ubuntu (ubuntu16.04 安装指南,chrome安装,vim配置,git设置和github,装QQ)

    日常手贱把ubuntu14.04更新到了16.04,然后就game over了.mdzz,不然泥萌也看不到这篇博客了=.= 然后花了些时间重装了一个16.04版的,原来那个14.04的用可以用,就是动 ...

  9. 快速学习C语言三: 开发环境, VIM配置, TCP基础,Linux开发基础,Socket开发基础

    上次学了一些C开发相关的工具,这次再配置一下VIM,让开发过程更爽一些. 另外再学一些linux下网络开发的基础,好多人学C也是为了做网络开发. 开发环境 首先得有个Linux环境,有时候家里机器是W ...

随机推荐

  1. python 随机选择字符串中的一个字符

    import random print(random.choice('abcdefghijklm'))

  2. c语言 找最小值

    #include <stdio.h> #define N 10 #define MIN(X,Y) ((X<Y)?(X):(Y)) int f(int arr[],int len,in ...

  3. 使用Spring Loader或者Jrebel实现java 热部署

    .其实JRebel和Spring-Loaded就是一个开发环境下的利器,skip build and redeploy process,大大提升了工作效率!而非生产环境的利器...因为线上reload ...

  4. 从0开始springboot

    http://412887952-qq-com.iteye.com/blog/2291500

  5. 判断是否是iPhone5

    #define IS_IPHONE_5 ( fabs( ( double )[ [ UIScreen mainScreen ] bounds ].size.height - ( double )568 ...

  6. 内存泄漏 之 MAT工具的使用

    1 内存泄漏的排查方法 Dalvik Debug Monitor Server (DDMS) 是 ADT插件的一部分,其中有两项功能可用于内存检查 : ·    heap 查看堆的分配情况 ·     ...

  7. C# Seal用法

    C# Seal用法 sealed的中文意思是密封,故名思义,就是由它修饰的类或方法将不能被继承或是重写. sealed关键字的作用:     在类声明中使用sealed可防止其它类继承此类:在方法声明 ...

  8. Git 将代码恢复到一个历史的版本

    Git 将代码恢复到一个历史的版本 要把代码回到某个历史版本 比如 test有两种方法 暴力的方式 如果你的仓库是自己在用(不影响别人),那么你可以使用 git reset --hard <ta ...

  9. BZOJ3211: 花神游历各国(线段树)

    3211: 花神游历各国 Time Limit: 5 Sec  Memory Limit: 128 MBSubmit: 5692  Solved: 2114[Submit][Status][Discu ...

  10. bzoj 4177 Mike的农场

    bzoj 4177 Mike的农场 思维有些江化了,一上来就想费用流做法,但其实就是个最小割啊. 考虑先将所有的收益拿到,再减去不能拿的以及三元组 \((i,j,k)\) 产生的代价.即,先让 \(a ...