我的vim配置文件如下:

"根据时段的不同自动选择不同的配色方案

""if strftime("%H") < 6 "6:00

    ""colorscheme guodesert

""elseif strftime("%H") > 18 "18:00

""colorscheme guodesert

    ""else        "18:00

""colorscheme guogithub

""endif





autocmd InsertLeave * set nocul "浅色显示高亮行,离开时关闭

autocmd InsertLeave * set nocuc "浅色显示高亮行,离开时关闭

autocmd InsertEnter * set cul "浅色显示高亮行,进入时浅色显示打开

autocmd InsertEnter * set cuc "浅色显示高亮行,进入时浅色显示打开





let &t_SI = "\<Esc>]50;CursorShape=0\x7"

let &t_EI = "\<Esc>]50;CursorShape=1\x7"

"*****************************************选项设置**********************************************

set nocompatible "关闭vi兼容模式

syntax on "语法高亮

set t_Co=256 "开启vim的256颜色支持

colorscheme guodesert "设定配色方案

set nobackup "覆盖文件时不备份

set autoindent "插入模式下输入<cr>或使用"o"或"O"命令开新行,从当前行复制缩进距离

set shiftwidth=4 "(自动)缩进每一步使用的空白数目

set softtabstop=4 "执行插入时,<Tab>算作空格的数目,可以改为4

set noexpandtab "不用空格展开<Tab>

set scrolloff=2 "光标上下两侧最少保留的屏幕行数

set sidescrolloff=5 "如果设置'nowrap',光标左右两侧保留的最少屏幕列数

set sidescroll=1 "水平滚动时滚动的最少列数

set showcmd "在屏幕最后一行显示 (部分的) 命令

set showmode "在插入、替换和可视模式里,在最后一行提供消息

set hidden "放弃时隐藏缓冲区

set wildmenu "'wildmenu'打开时,命令行补全以增强模式运行

set wildmode=list:full "用'widechar'指定的字符所用的补全模式

set novisualbell "不使用可视响铃

set number "在每行前面显示行号

set numberwidth=3 "行号使用的最小列数

set ignorecase "搜索模式里忽略大小写

set smartcase "搜索模式里包含大写字符,不使用ignorecase选项

set incsearch "输入搜索命令时,显示目前输入的模式的匹配位置。匹配的字符串被高亮

"set hlsearch "搜索时高亮显示被找到的文本

set showmatch "插入括号时,短暂地跳转到匹配的对应括号 

set matchtime=5 "短暂跳转到匹配括号的时间

set textwidth=108 "设定文本的宽度为80个字符时自动断行

"set columns=75 "设置文本达到columns宽度时自动换行

set wrap    
"设置文本达到textwidth宽度时自动换行,但实际文件还是一行

"set nowrap "设置文本达到textwidth宽度时不自动换行

"set complete+=k "关键字补全,扫描 'dictionary' 选项给出的文件

set history=50 "命令的历史和最近的搜索模式的历史被记住。本项决定每个历史分别记多少项 

set wildignore+=*.svn "文件名补全时忽略.svn 

set nosplitbelow "窗口的分割会把新窗口放到当前窗口之下

set nosplitright "窗口的分割会把新窗口放到当前窗口之右

set background=dark "设置背景为暗色

set virtualedit+=block "在可视模式下可以选择一个方块

set autoread "当文件在外部被修改时,自动重新读取

set autowrite "自动保存文件

"set cmdheight=2 "设定命令行的行数为1

"set cuc "将当前光标下的列高亮

set autochdir "自动切换当前目录为当前文件所在的目录

set helplang=cn "设置帮助语言

set iskeyword+=_,$,@,%,#,- "带有这些字符的单词不要被换行分割

set backspace=2 "使用回格键

set backspace=indent,eol,start "影响 <BS>、<Del>、CTRL-W和CTRL-U在插入模式下的工作方式

set noswapfile "没有交换文件

"set undofile "持久撤销功能

filetype plugin indent on "文件类型侦测 

set foldlevel=99 "设置折叠级别: 高于此级别的折叠会被关闭

set foldclose=all "设置为自动关闭折叠 

set foldenable "开始折叠

set foldmethod=syntax "语法高亮项目指定折叠

set foldcolumn=0 "设置折叠区域的宽度,显示折叠列

set cursorline "突出显示当前行

"set cursorcolumn "突出显示当前列

set ruler  
"显示状态栏标尺

set rulerformat =%33(%2*%<%=\修改:\%{strftime(\"%H:%M\",getftime(expand(\"%\")))}\ 光标:\%l\行\ %c%V\列\ %p%%%)

"set rulerformat =%25(%2*%<%=\光标:\ %l\行\ %c%V\列\ %p%%%)





set fencs=utf-8,ucs-bom,shift-jis,gb18030,gbk,gb2312,cp936  "设置编码

" set cursorline

set smartindent  "开启新行时使用智能自动缩进





"*****************************************高亮设置**********************************************

hi CursorLine   ctermfg=NONE ctermbg=235cterm=NONEguibg=NONEguifg=NONE   "指定高亮的规则bg=235

"*****************************************高亮设置**********************************************





"描述自动排版如何进行的字母序列

set formatoptions+=q

set formatoptions+=r

set formatoptions+=n

"set formatoptions+=1

"set colorcolumn=+1

"set list "让tab显示成>-------->--------

"set listchars=tab:>-,trail:-,extends:>,precedes:<
"配合上边的语句完成

"#########################################选项设置##############################################





" 为C程序提供自动缩进

"set smartindent 

"代码补全

"set completeopt=preview,menu 

"自动补全

:inoremap ( ()<ESC>i

:inoremap ) <c-r>=ClosePair(')')<CR> 

:inoremap { {<CR>}<ESC>O

:inoremap } <c-r>=ClosePair('}')<CR> 

:inoremap [ []<ESC>i

:inoremap ] <c-r>=ClosePair(']')<CR> 

:inoremap " ""<ESC>i

:inoremap ' ''<ESC>i

function ClosePair(char) 

"if getline('.')[col('.') - 1 ] == a:char

if getline('.') == a:char 

return "\<Right>" 

else 

return a:char 

endif 

endfunction 

"filetype plugin indent on 

"打开文件类型检测, 加了这句才可以用智能补全

"set completeopt=longest,menu 





"启用代码折叠,用空格键来开关折叠   

nnoremap <space> @=((foldclosed(line('.')) < 0) ? 'zc':'zo')<CR>   





"===========================================其他按键映射========================================

"nnoremap j gj "自动换行时可在行中移动

"nnoremap k gk

nnoremap <C-h> <C-w>h "在分割的窗口间移动

nnoremap <C-j> <C-w>j

nnoremap <C-k> <C-w>k

nnoremap <C-l> <C-w>l

noremap <S-h> :bp<cr> "在buffer间移动

noremap <S-l> :bn<cr>

map + <C-w>+ "增减窗口尺寸

map _ <C-w>-

map e ea  
"移动到单词结尾时就自动进入插入模式

nnoremap <space> @=((foldclosed(line('.')) < 0) ? 'zc' : 'zo')<CR>  "用空格键来开关折叠

"file list

map <silent> <F2> :NERDTreeToggle<cr>

"tarbar functon list

map <silent> <F3> :TagbarToggle<cr>

"header and implement file switch

map <F4> :A<cr>

"update index

map <F5> :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q<cr><cr>:cs kill cscope.out<cr>:!cscope -Rb<cr><cr>:cs add cscope.out<cr>

"switch display invisable char or not

map <F6> :set list!<cr>:set list?<cr>

"highlight

map <F7> ms:%s /\<<C-R>=expand("<cword>")<CR>\>//gn<cr>`s

"swapfile list

map <silent> <F8> :BufExplorer<CR>

"comment visual line

vnoremap <silent> , :call NERDComment(1, "alignLeft")<cr>

"uncomment visual line

vnoremap <silent> . :call NERDComment(1, "uncomment")<cr>

"show list if more tag 

nnoremap <c-]> g<c-]>

"move to right window

noremap <c-l> <c-w>l

"move to up window

noremap <c-k> <c-w>k

"move to down window

noremap <c-j> <c-w>j

"move to left window

noremap <c-h> <c-w>h

"goto the place where word definition

nmap <C-[>g :cs find g <C-R>=expand("<cword>")<CR><CR>

"list the funcion called by this function

nmap <C-[>d :cs find d <C-R>=expand("<cword>")<CR><CR>

"list the position where to call this word

nmap <C-[>c :cs find c <C-R>=expand("<cword>")<CR><CR>

"search word in the project

nmap <C-[>s :cs find s <C-R>=expand("<cword>")<CR><CR>

"search word in the project and the word can be in text

nmap <C-[>t :cs find t <C-R>=expand("<cword>")<CR><CR>

"search word in the project and the word can be in text, support regex

nmap <C-[>e :cs find e <C-R>=expand("<cword>")<CR><CR>

"list the file which filename is this word

nmap <C-[>f :cs find f <C-R>=expand("<cfile>")<CR><CR>

"list the file include the file which filename is this word

nmap <C-[>i :cs find i ^<C-R>=expand("<cfile>")<CR>$<CR>

"list the file which include this file

nmap <C-[>I :cs find i <C-R>=expand("%:t")<CR><CR>





if has("cscope") 

    set nocsverb

    if filereadable("cscope.out")

        cs add cscope.out

    endif

endif

"##########################################其他按键映射#########################################





"================================打开文件时,自动跳转到光标最后所在的位置============================

"打开文件时,自动跳转到光标最后所在的位置

if has("autocmd")

   au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$")

     \| exe "normal! g'\"" | endif

 endif

"###########################打开文件时,自动跳转到光标最后所在的位置#######################





"通过键盘映射快速实现加入注释。

"==========================================添加注释语句==========================================

  "将键盘上的F10功能键映射为添加作者信息的快捷键%m月%d日%Y年 

  "进行版权声明的设置

  "添加或更新头

  map <F10> :call TitleDet()<cr>

  

  function AddTitle()

    call append(0,"/* *========* *** *================================================================= ")

    call append(1,"  * 作者代号: *** :×××××××××××××")

    call append(2,"  * 版权声明: *** :(魎魍魅魑)GPL3")

    call append(3,"  * 联络信箱: *** ×××××××××××××")

    call append(4,"  * 文档用途: *** :深入理解C指针")  

    call append(5,"  * 文档信息: *** :".expand("%:p:~"))

    call append(6,"  * 修订时间: *** :".strftime("%Y年第%W周 %m月%d日 %A %p%I:%M (%j天)"))

    call append(7,"  * 代码说明: *** :自行添加")

    call append(8," * *========* *** *================================================================= */")

    "echohl WarningMsg | echo "Successful in adding the copyright." | echohl None

  endf

  "更新最近修改时间和文件名

  function UpdateTitle()

    normal m'

    execute '/修订时间:/s@:.*$@\=strftime(": *** *%Y年第%W周 %m月%d日 %A %p%I:%M (%j天)")@'

    normal ''

    normal mk

    execute '/文档信息:/s@:.*$@\=": *** :".expand("%:p:~")@'

    execute "noh"

    normal 'k

    "echohl WarningMsg | echo "Successful in updating the copy right." | echohl None

  endfunction

  "判断前10行代码里面,是否有Last modified这个单词,

  "如果没有的话,代表没有添加过作者信息,需要新添加;

  "如果有的话,那么只需要更新即可

  function TitleDet()

    let n=1

    "默认为添加

    while n < 10

        let line = getline(n)

        if line =~ '^\ \ \**\s*\S*修订时间:\S*.*$'

call UpdateTitle()

            return

        endif

        let n = n + 1

    endwhile

    call AddTitle()

  endfunction  

"##########################################添加注释语句##########################################





"通过键盘映射快速实现编译与运行。

"==========================================编译运行程序==========================================

  "将键盘上的F9功能键映射为添加作者信息的快捷键%m月%d日%Y年 

  "进行版权声明的设置

  "添加或更新头

  map <F9> :call CompileRun()<cr>

  function CompileRun()

    exec "w"

    if &filetype == 'c'

exec "!gcc -g % -o %<"

exec "!%<"

    elseif &filetype == 'cpp'

exec "!g++ -g % -o %<"

exec "!%<"

    elseif &filetype == 'java'

exec "!javac %"

exec "!java %<"

    else

exec "echo not support filetype!"

    endif

  endfunction

"##########################################添加注释语句#########################################





let NERDTreeQuitOnOpen=1

let NERDTreeDirArrows=0

let NERDTreeWinSize=40

let NERDRemoveExtraSpaces=0

let g:bufExplorerDisableDefaultKeyMapping = 1

let g:acp_behaviorKeywordCommand = "\<C-o>"

let g:acp_behaviorKeywordLength = -1

let g:acp_behaviorFileLength = -1

let g:SuperTabDefaultCompletionType = "<c-n>"

let g:SuperTabLongestHighlight = 1

let g:tagbar_sort=0

let g:tagbar_compact=1

let g:tagbar_foldlevel=1

let g:tagbar_iconchars=['+', '-']

let OmniCpp_SelectFirstItem = 2

let OmniCpp_ShowPrototypeInAbbr = 1 

let OmniCpp_MayCompleteScope = 1





"试试缩写好用吗

 ab psvm public static void main 

 "ab sop System.out.println

vim配置文件解析的更多相关文章

  1. Linux 网络配置文件解析

    Linux 网络配置文件解析 网络配置文件路径/etc/sysconfig/network-scripts/ifcfg-*     *代表网卡名 vim /etc/sysconfig/network- ...

  2. Argo 安装和 workflow 实例配置文件解析

    一.Argo 安装配置 1.1 Argo 安装 $ kubectl create ns argo $ kubectl apply -n argo -f https://raw.githubuserco ...

  3. Vim配置文件

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

  4. MyBatis配置文件解析

    MyBatis配置文件解析(概要) 1.configuration:根元素 1.1 properties:定义配置外在化 1.2 settings:一些全局性的配置 1.3 typeAliases:为 ...

  5. 我的vim配置文件.vimrc

    我的vim配置文件.vimrc map <silent> <F10> :TlistToggle<cr>map <silent> <F8> : ...

  6. Nginx安装与配置文件解析

    导读 Nginx是一款开放源代码的高性能HTTP服务器和反向代理服务器,同时支持IMAP/POP3代理服务,是一款自由的软件,同时也是运维工程师必会的一种服务器,下面我就简单的说一下Nginx服务器的 ...

  7. Hadoop配置文件解析

    Hadoop源码解析 2 --- Hadoop配置文件解析 1 Hadoop Configuration简介    Hadoop没有使用java.util.Properties管理配置文件, 也没有使 ...

  8. 转载~vim配置文件

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

  9. Python3 配置文件 解析

    /************************************************************************ * Python3 配置文件 解析 * 说明: * ...

随机推荐

  1. 三次样条插值matlab实现

    三次样条插值matlab实现 %三次样条差值-matlab通用程序 - zhangxiaolu2015的专栏 - CSDN博客 https://blog.csdn.net/zhangxiaolu201 ...

  2. 信号量和互斥量C语言示例理解线程同步

    Table of Contents 1. 线程同步 1.1. 用信号量进行同步 1.2. 用互斥量进行同步 2. 参考资料 线程同步 了解线程信号量的基础知识,对深入理解python的线程会大有帮助. ...

  3. WTForm

    Flask-WTForm: from flask import Flask,render_template,request,redirect from wtforms.fields import co ...

  4. Bug的类型

    美国计算机科学家.图灵奖获得者詹姆斯·尼古拉·格雷(Jim Gray),在他的著名的论文“Why do computers stop and what can be done about it?”中首 ...

  5. python - 接口自动化测试 - RunTest - 测试用例加载执行/测试报告生成

    # -*- coding:utf-8 -*- ''' @project: ApiAutoTest @author: Jimmy @file: run_test.py @ide: PyCharm Com ...

  6. JMeter非GUI界面运行

    JMeter是一款可以用于做接口可以用于作压力性能的应用程序,该程序是纯Java语音开发,所有对环境支持都比较好. JMeter可以运行模式有两种,一种是UI图形,另一种是命令模式运行也就是非GUI模 ...

  7. Leetcode 654.最大二叉树

    最大二叉树 给定一个不含重复元素的整数数组.一个以此数组构建的最大二叉树定义如下: 二叉树的根是数组中的最大元素. 左子树是通过数组中最大值左边部分构造出的最大二叉树. 右子树是通过数组中最大值右边部 ...

  8. 【转】深入理解 C# 协变和逆变

    http://www.cnblogs.com/qixuejia/p/4383068.html 深入理解 C# 协变和逆变   msdn 解释如下: “协变”是指能够使用与原始指定的派生类型相比,派生程 ...

  9. jquery对象与js对象

    对于已经是一个 DOM 对象,只需要用 $() 把DOM对象包装起来,就可以获得一个 jQuery 对象了,使用[index]和.get(index)可以转为DOM对象 jQuery 对象是通过 jQ ...

  10. 多IP指定出口IP地址 如何指定云服务器源IP?

    如果一个主机绑定有多个IP地址,那么在被动响应和主动发起连接两种方式中,源IP地址的选择机制肯定是有所差异的.主机在接收外部数据包,并发送响应数据包时,响应源地址显然就是客户端请求的地址,这是非常容易 ...