我的vim配置文件,适合大多数人习惯

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 一般设定
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 设定默认解码
set fenc=utf-
set fencs=utf-,usc-bom,euc-jp,gb18030,gbk,gb2312,cp936 " 不要使用vi的键盘模式,而是vim自己的
set nocompatible " history文件中需要记录的行数
set history= " 在处理未保存或只读文件的时候,弹出确认
set confirm " 与windows共享剪贴板
set clipboard+=unnamed " 侦测文件类型
filetype on " 载入文件类型插件
filetype plugin on " 为特定文件类型载入相关缩进文件
filetype indent on " 保存全局变量
set viminfo+=! " 带有如下符号的单词不要被换行分割
set iskeyword+=_,$,@,%,#,- " 语法高亮
syntax on " 高亮字符,让其不受100列限制
:highlight OverLength ctermbg=red ctermfg=white guibg=red guifg=white
:match OverLength '\%101v.*' " 状态行颜色
highlight StatusLine guifg=SlateBlue guibg=Yellow
highlight StatusLineNC guifg=Gray guibg=White """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 文件设置
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 不要备份文件(根据自己需要取舍)
set nobackup " 不要生成swap文件,当buffer被丢弃的时候隐藏它
setlocal noswapfile
set bufhidden=hide " 字符间插入的像素行数目
set linespace= " 增强模式中的命令行自动完成操作
set wildmenu " 在状态行上显示光标所在位置的行号和列号
set ruler
set rulerformat=%(%*%<%f%=\ %m%r\ %3l\ %c\ %p%%%) " 命令行(在状态行下)的高度,默认为1,这里是2
set cmdheight= " 使回格键(backspace)正常处理indent, eol, start等
set backspace= " 允许backspace和光标键跨越行边界
set whichwrap+=<,>,h,l " 可以在buffer的任何地方使用鼠标(类似office中在工作区双击鼠标定位)
set mouse=a
set selection=exclusive
set selectmode=mouse,key " 启动的时候不显示那个援助索马里儿童的提示
set shortmess=atI " 通过使用: commands命令,告诉我们文件的哪一行被改变过
set report= " 不让vim发出讨厌的滴滴声
set noerrorbells " 在被分割的窗口间显示空白,便于阅读
set fillchars=vert:\ ,stl:\ ,stlnc:\ """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 搜索和匹配
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 高亮显示匹配的括号
set showmatch " 匹配括号高亮的时间(单位是十分之一秒)
set matchtime= " 在搜索的时候忽略大小写
set ignorecase " 不要高亮被搜索的句子(phrases)
set nohlsearch " 在搜索时,输入的词句的逐字符高亮(类似firefox的搜索)
set incsearch " 输入:set list命令是应该显示些啥?
set listchars=tab:\|\ ,trail:.,extends:>,precedes:<,eol:$ " 光标移动到buffer的顶部和底部时保持3行距离
set scrolloff= " 不要闪烁
set novisualbell " 我的状态行显示的内容(包括文件类型和解码)
set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [POS=%l,%v][%p%%]\ %{strftime(\"%d/%m/%y\ -\ %H:%M\")} " 总是显示状态行
set laststatus= """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 文本格式和排版
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 自动格式化
set formatoptions=tcrqn " 继承前一行的缩进方式,特别适用于多行注释
set autoindent " 为C程序提供自动缩进
set smartindent " 使用C样式的缩进
" set cindent " 制表符为4
set tabstop= " 统一缩进为4
" set softtabstop=
set shiftwidth= " 不要用空格代替制表符
set expandtab
" 如果改成set noexpandtab就是不用四个空格代替一个table " 不要换行
set nowrap " 在行和段开始处使用制表符
set smarttab """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" CTags的设定
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 按照名称排序
let Tlist_Sort_Type = "name" " 在右侧显示窗口
let Tlist_Use_Right_Window = " 压缩方式
let Tlist_Compart_Format = " 如果只有一个buffer,kill窗口也kill掉buffer
let Tlist_Exist_OnlyWindow = " 不要关闭其他文件的tags
let Tlist_File_Fold_Auto_Close = " 不要显示折叠树
let Tlist_Enable_Fold_Column = """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Autocommands
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 只在下列文件类型被侦测到的时候显示行号,普通文本文件不显示 if has("autocmd")
autocmd FileType xml,html,c,cs,java,perl,shell,bash,cpp,python,vim,php,ruby set number
autocmd FileType xml,html vmap <C-o> <ESC>'<i<!--<ESC>o<ESC>'>o-->
autocmd FileType java,c,cpp,cs vmap <C-o> <ESC>'<o/*<ESC>'>o*/
autocmd FileType html,text,php,vim,c,java,xml,bash,shell,perl,python setlocal textwidth=
autocmd Filetype html,xml,xsl source $VIMRUNTIME/plugin/closetag.vim
autocmd BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal g`\"" |
\ endif
endif " has("autocmd") " F5编译和运行C程序,F6编译和运行C++程序
" 请注意,下述代码在windows下使用会报错
" 需要去掉./这两个字符 " C的编译和运行 func! CompileRunGcc()
exec "w"
silent exec "!gcc % -o %<"
exec "! ./%<"
endfunc " C++的编译和运行 func! CompileRunGpp()
exec "w"
silent exec "!g++ % -o %<"
exec "! ./%<"
endfunc func! CompileCode()
if &filetype == "c"
exec "call CompileRunGcc()"
elseif &filetype == "cpp"
exec "call CompileRunGpp()"
endif
endfunc
map<F6> :call CompileCode()<CR> map <F4> :call TitleDet2() <cr>
function AddTitle2()
call append(,"/************************************************************")
call append(," * Author : xiaxiaosheng")
call append(," * Email : x810429187@qq.com ")
call append(," * Last modified : ".strftime("%Y-%m-%d %H:%M"))
call append(," * Filename : ".expand("%:t"))
call append(," * Description :" )
call append(," * *********************************************************/")
echohl WarningMsg |echo "Successful in adding the copyright." | echohl None
endf function UpdateTitle2()
normal m'
execute '/# *Last modified:/s@:.*$@\=strftime(":\t%Y-%m-%d %H:%M")@'
normal ''
normal mk
execute '/# *Filename:/s@:.*$@\=":\t\t".expand("%:t")@'
execute "noh"
normal 'k
echohl WarningMsg | echo "Successful in updating the copy right." | echohl None
endfunction function TitleDet2()
let n=
while n <
let line = getline(n)
if line =~ '^\#\s*\S*Last\smodified:\S*.*$'
call UpdateTitle2()
return
endif
let n = n+
endwhile
call AddTitle2()
endfunction autocmd BufNewFile *.c,*.py,*.cpp,*.sh,*.java exec ":call SetTitle()"
func SetTitle() if &filetype == 'sh'
call setline(,"\#!/bin/bash")
call append(line("."), "# Author: xiaxiaosheng")
call append(line(".")+, "# Created Time: ".strftime("%c"))
call append(line(".")+, "")
elseif &filetype == 'cpp'
call setline(,"// File Name: ".expand("%"))
call append(line("."), "// Author: xiaxiaosheng")
call append(line(".")+, "// Created Time: ".strftime("%c"))
call append(line(".")+, "")
call append(line(".")+, "#include<vector>")
call append(line(".")+, "#include<list>")
call append(line(".")+, "#include<map>")
call append(line(".")+, "#include<set>")
call append(line(".")+, "#include<deque>")
call append(line(".")+, "#include<stack>")
call append(line(".")+, "#include<bitset>")
call append(line(".")+, "#include<algorithm>")
call append(line(".")+, "#include<functional>")
call append(line(".")+, "#include<numeric>")
call append(line(".")+, "#include<utility>")
call append(line(".")+, "#include<sstream>")
call append(line(".")+, "#include<iostream>")
call append(line(".")+, "#include<iomanip>")
call append(line(".")+, "#include<cstdio>")
call append(line(".")+, "#include<cmath>")
call append(line(".")+, "#include<cstdlib>")
call append(line(".")+, "#include<cstring>")
call append(line(".")+, "#include<ctime>")
call append(line(".")+, "")
call append(line(".")+, "using namespace std;")
call append(line(".")+, "")
call append(line(".")+, "int main(){")
call append(line(".")+26,"")
call append(line(".")+27, "return 0;")
call append(line(".")+28, "}") elseif &filetype == 'python'
call setline(,"\#!/usr/bin/env python")
call append(line("."), "# Author: xiaxiaosheng")
call append(line(".")+, "# Created Time: ".strftime("%c"))
call append(line(".")+, "")
elseif &filetype == 'c'
call setline(,"// File Name: ".expand("%"))
call append(line("."), "// Author: xiaxiaosheng")
call append(line(".")+, "// Created Time: ".strftime("%c"))
call append(line(".")+, "")
call append(line(".")+,"#include<stdio.h>")
call append(line(".")+,"#include<string.h>")
call append(line(".")+,"#include<stdlib.h>")
call append(line(".")+,"#include<time.h>")
call append(line(".")+,"#include<math.h>")
call append(line(".")+,"")
call append(line(".")+,"int main(){")
call append(line(".")+10,"")
call append(line(".")+11,"return 0 ;")
call append(line(".")+12,"}")
else
call setline(,"/*")
call append(line("."), "* Author: rechen")
call append(line(".")+, "* Created Time: ".strftime("%c"))
call append(line(".")+, "*/")
call append(line(".")+, "")
endif autocmd BufNewFile * normal G
endfunc " 能够漂亮地显示.NFO文件
set encoding=utf-
function! SetFileEncodings(encodings)
let b:myfileencodingsbak=&fileencodings
let &fileencodings=a:encodings
endfunction
function! RestoreFileEncodings()
let &fileencodings=b:myfileencodingsbak
unlet b:myfileencodingsbak
endfunction au BufReadPre *.nfo call SetFileEncodings('cp437')|set ambiwidth=single
au BufReadPost *.nfo call RestoreFileEncodings() " 高亮显示普通txt文件(需要txt.vim脚本)
au BufRead,BufNewFile * setfiletype txt " 用空格键来开关折叠
set foldenable
set foldmethod=manual
nnoremap <space> @=((foldclosed(line('.')) < ) ? 'zc' : 'zo')<CR> " minibufexpl插件的一般设置
let g:miniBufExplMapWindowNavVim =
let g:miniBufExplMapWindowNavArrows =
let g:miniBufExplMapCTabSwitchBufs =
let g:miniBufExplModSelTarget =

标准vim配置文件 带注释(适合C++编译)的更多相关文章

  1. 一套强大的vim配置文件+详细注释

    phpchina折腾王独家配置,灰常牛叉的一套vim配置,另附有详细注释,自己折腾vim的时候可以参照其中的大部分设置进行一些个性化定制."是否兼容VI,compatible为兼容,noco ...

  2. vim 配置文件 ,高亮+自动缩进+行号+折叠+优化

    vim 配置文件 ,高亮+自动缩进+行号+折叠+优化 将一下代码copy到 用户目录下 新建文件为  .vimrc保存即可生效: 如果想所有用户生效 请修改 /etc/vimrc (建议先cp一份)& ...

  3. vim配置文件和插件管理

    本文通过总结零碎的资料总结而成,更多是去引导学习vim配置文件及插件使用. .vimrc配置文件,内容如下(备注清晰) "引入插件pathogen使用 execute pathogen#in ...

  4. Vim配置文件

    转载 原文网址:http://www.cnblogs.com/ma6174/archive/2011/12/10/2283393.html 花了很长时间整理的,感觉用起来很方便,共享一下. 我的vim ...

  5. 转载~vim配置文件

    转载自:小码哥的博客 花了很长时间整理的,感觉用起来很方便,共享一下. 我的vim配置主要有以下优点: 1.按F5可以直接编译并执行C.C++.java代码以及执行shell脚本,按“F8”可进行C. ...

  6. 【转】强大的vim配置文件,让编程更随意

    原文地址:http://www.cnblogs.com/ma6174/archive/2011/12/10/2283393.html 花了很长时间整理的,感觉用起来很方便,共享一下. 我的vim配置主 ...

  7. [转]强大的vim配置文件,让编程更随意

    转自:http://www.cnblogs.com/ma6174/archive/2011/12/10/2283393.html 花了很长时间整理的,感觉用起来很方便,共享一下. 我的vim配置主要有 ...

  8. 强大的vim配置文件,让编程更随意

    花了很长时间整理的,感觉用起来很方便,共享一下. 我的vim配置主要有以下优点: 1.按F5可以直接编译并执行C.C++.java代码以及执行shell脚本,按“F8”可进行C.C++代码的调试 2. ...

  9. 强大的vim配置文件,让编程更随意 (转载)

    花了很长时间整理的,感觉用起来很方便,共享一下. 我的vim配置主要有以下优点: 1.按F5可以直接编译并执行C.C++.java代码以及执行shell脚本,按“F8”可进行C.C++代码的调试 2. ...

随机推荐

  1. HBase 架构与工作原理3 - HBase 读写与删除原理

    本文系转载,如有侵权,请联系我:likui0913@gmail.com 一.前言 在 HBase 中,Region 是有效性和分布的基本单位,这通常也是我们在维护时能直接操作的最小单位.比如当一个集群 ...

  2. PHP ini_set

    PHP ini_set用来设置php.ini的值,在函数执行的时候生效,对于虚拟空间来说,很方便,下面为大家介绍下此方法的使用   PHP ini_set用来设置php.ini的值,在函数执行的时候生 ...

  3. JDBC的基础接口及其用法

    JDBC基础 所谓JDBC即是:Java DataBase Connectivity,java与数据库的连接.是一些用来执行SQL语句的Java API. 我们进行JDBC的编程,主要常用的几个概念: ...

  4. mysql 读写锁

    1. 表读锁 lock table tablename read; 例如: 从上图中可以看到,当给表a加了读锁之后,该进程本身对表a是可读的,但是不可写,再看在另外一个进程中: 在另外一个进程中表a也 ...

  5. JavaScript本地存储实践(html5的localStorage和ie的userData)

    http://www.css88.com/archives/3717 JavaScript本地存储实践(html5的localStorage和ie的userData) 发表于 2011年06月11日  ...

  6. 浅析Web数据存储-Cookie、UserData、SessionStorage、WebSqlDatabase

    Cookie 它是标准的客户端浏览器状态保存方式,可能在浏览器诞生不久就有Cookie了,为什么需要Cookie 这个东东?由于HTTP协议没有状态,所以需要一个标志/存储来记录客户浏览器当前的状态, ...

  7. Go 示例测试实现原理剖析

    简介 示例测试相对于单元测试和性能测试来说,其实现机制比较简单.它没有复杂的数据结构,也不需要额外的流程控制,其核心工作原理在于收集测试过程中的打印日志,然后与期望字符串做比较,最后得出是否一致的报告 ...

  8. Spring boot项目集成Sharding Jdbc

    环境 jdk:1.8 framework: spring boot, sharding jdbc database: MySQL 搭建步骤 在pom 中加入sharding 依赖 <depend ...

  9. BZOJ.1036 [ZJOI2008]树的统计Count ( 点权树链剖分 线段树维护和与最值)

    BZOJ.1036 [ZJOI2008]树的统计Count (树链剖分 线段树维护和与最值) 题意分析 (题目图片来自于 这里) 第一道树链剖分的题目,谈一下自己的理解. 树链剖分能解决的问题是,题目 ...

  10. docker虚拟机动态扩展内存

    需求:将一台docker虚拟机的内存从6G扩展到8G. 关于资源限制,docker使用的是cgroup,这里就不细说原理了,只记录一下操作方法. 1.先找到容器ID # docker ps 2.进入对 ...