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

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

自动匹配括号,引号等

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. pairs 和 ipairs 的区别

    ipairs 在迭代过程中是会直接跳过所有手动设定key值的变量.pairs不会跳过手动设置key值的变量. 实例 tab = {,,a="cd","d"} f ...

  2. JVM史上最佳入门指南

    提到Java虚拟机(JVM),可能大部分人的第一印象是“难”,但当让我们真正走入“JVM世界”的时候,会发现其实问题并不像我们想象中的那么复杂.唯一真正令我们恐惧的,其实是恐惧本身.而作为整个JVM系 ...

  3. vue 脚手架(一,创建脚手架)

    本文以转移至本人的个人博客,请多多关注! 本文以转移至本人的个人博客,请多多关注! 本文以转移至本人的个人博客,请多多关注! 本文以转移至本人的个人博客,请多多关注! 经过一段时间对Vue的学习.觉得 ...

  4. Spring中<bean>标签之使用p标签配置bean的属性

    在spring的bean配置文件中我们常可以见到下面的例子: <bean id="user" class="com.sys.User" p:name-re ...

  5. Leetcode 35

    //在数组最后插入INT_MAX是个好方法class Solution { public: int searchInsert(vector<int>& nums, int targ ...

  6. Java9新特性

    转载:http://blog.csdn.net/qq_32524177/article/details/77014757 写在前面的话:Java9来了,搜索了很多关于Java9的新特性,但文献不多,特 ...

  7. bzoj1224

    题解: 暴力+剪纸 判断一下最大行不行,最小行不行 代码: #include<bits/stdc++.h> ; using namespace std; ],q; int n,m,x,y, ...

  8. 如何在JavaScript中手动创建类数组对象

    前言 关于什么是js的类数组对象这里不再赘述.可以参考这个链接,还有这里. js中类数组对象很多,概念简单的讲就是看上去像数组,又不是数组,可以使用数字下标方式访问又没有数组方法. 例: argume ...

  9. STL标准库-容器-forward_list

    技术在于交流.沟通,本文为博主原创文章转载请注明出处并保持作品的完整性. forward_list即单向list,功能少额外开销就小.而且只能在前段插入元素 结构如下 一 定义 #include &l ...

  10. 面试题总结(一)、TCP协议

    声明:本文主要探讨当TCP协议出现在面试笔试场合可能会涉及的问题,每一个知识点讨论力求简洁,便于记忆,但讨论深度有限,如要深入研究可点击参考链接,希望对正在找工作的同学有点帮助. 一.TCP协议简介 ...