1 "My .vimrc 2 "2016-04-10 3 4 5 au FileType php setlocal dict+=~/.vim/dict/php_funclist.dict 6 au FileType css setlocal dict+=~/.vim/dict/css.dict 7 au FileType c setlocal dict+=~/.vim/dict/c.dict 8 au FileType cpp setlocal dict+=~/.vim/dict/cpp.dict 9 au FileType scale setlocal dict+=~/.vim/dict/scale.dict 10 au FileType javascript setlocal dict+=~/.vim/dict/javascript.dict 11 au FileType html setlocal dict+=~/.vim/dict/javascript.dict 12 au FileType html setlocal dict+=~/.vim/dict/css.dict 13 14 15 "去掉 16 "去掉启动时的援助乌干达儿童的提示 17 set shortmess=atI 18 "去掉讨厌的有关vi一致性模式 19 set nocompatible 20 "去掉输入错误的提示声音 21 set noeb 22 23 24 "显示中文帮助 25 if version >= 603 26 set helplang=cn 27 set encoding=utf-8 28 endif 29 30 31 "编码 32 "set fencs=utf-8,ucs-bom,shift-jis,gb18030,gbk,gb2312,cp936 33 "set termencoding=utf-8 34 "set encoding=utf-8 35 "set fileencodings=ucs-bom,utf-8,cp936 36 "set fileencoding=utf-8 37 38 39 "主题 40 "color desert 41 color ron 42 "color torte 43 "colorscheme murphy 44 "colorscheme elflord 45 46 47 "显示 48 set number 49 syntax on 50 "高亮光标所在行、列 51 set cul 52 "set cuc 53 "浅色高亮当前行 54 autocmd InsertEnter * se cul 55 "autocmd InsertLeave * se nocul 56 57 58 "状态栏 59 set ruler 60 set cc=81 61 set showcmd 62 "启动显示状态行(1),总是显示状态行(2) 63 set laststatus=2 64 "状态行显示的内容 65 set statusline=%F%m%r%h%w [%{&encoding}] [FORMAT=%{&ff}] [TYPE=%Y] [POS=%l,%v] [%p%%] %{strftime("%d/%m/%y - %H:%M")} 66 "命令行的高度,默认为1 67 set cmdheight=2 68 69 70 "对齐 ai ci si 71 set autoindent 72 set cindent 73 set smartindent 74 75 76 "Tab键 77 set tabstop=4 78 set softtabstop=4 79 set shiftwidth=4 80 "空格代替制表符 81 set expandtab 82 "行和段开始处使用制表符 83 set smarttab 84 85 86 "高亮显示匹配的括号 87 set showmatch 88 "匹配括号高亮的时间(单位是十分之一秒) 89 set matchtime=1 90 91 "自动补全 括号 引号 92 :inoremap ( ()<ESC>i 93 :inoremap ) <c-r>=ClosePair(')')<CR> 94 :inoremap { {<CR>}<ESC>O 95 :inoremap } <c-r>=ClosePair('}')<CR> 96 :inoremap [ []<ESC>i 97 :inoremap ] <c-r>=ClosePair(']')<CR> 98 :inoremap " ""<ESC>i 99 :inoremap ' ''<ESC>i 100 function! ClosePair(char) 101 if getline('.')[col('.') - 1] == a:char 102 return "<Right>" 103 else 104 return a:char 105 endif 106 endfunction 107 108 109 "搜索 110 set hlsearch 111 "set nohls 112 "即时搜素 113 set incsearch 114 "搜索默认不区分大小写 115 set ignorecase smartcase 116 "行内替换 117 set gdefault 118 119 120 "键盘 121 "以下3行命令将ctrl-s映射为保存 122 nnoremap <C-S> :w<CR> 123 vnoremap <C-S> <C-C>:w<CR> 124 inoremap <C-S> <C-O>:w<CR> 125 126 "映射全选+复制 ctrl+a 127 map <C-A> ggVGY 128 map! <C-A> <Esc>ggVGY 129 130 "选中状态下 Ctrl+c 复制 131 vmap <C-c> "+y 132 133 "F5编译运行 134 map <F5> :call CompileRunGcc()<CR> 135 func! CompileRunGcc() 136 exec "w" 137 if &filetype == 'c' 138 exec "!g++ % -o %<" 139 exec "! ./%<" 140 elseif &filetype == 'cpp' 141 exec "!g++ % -o %<" 142 exec "! ./%<" 143 elseif &filetype == 'java' 144 exec "!javac %" 145 exec "!java %<" 146 elseif &filetype == 'sh' 147 :!./% 148 elseif &filetype == 'py' 149 exec "!python %" 150 exec "!python %<" 151 endif 152 endfunc 153 154 "C,C++的调试 155 map <F8> :call Rungdb()<CR> 156 func! Rungdb() 157 exec "w" 158 exec "!g++ % -g -o %<" 159 exec "!gdb ./%<" 160 endfunc 161 162 163 "其他 164 "当文件被改动时自动载入 165 set autoread 166 "自动保存 167 set autowrite 168 "处理未保存或只读文件时,弹出确认 169 set confirm 170 "覆盖文件时不备份 171 set nobackup 172 "禁止生成临时文件 173 set noswapfile 174 "设置当前编辑的文件所在路径为工作路径 175 set autochdir 176 "历史记录数 177 set history=1000 178 "侦测文件类型 179 filetype on 180 "载入文件类型插件 181 filetype plugin on 182 "为特定文件类型载入相关缩进文件 183 filetype indent on 184 "保存全局变量 185 set viminfo+=! 186 "带有如下符号的单词不要被换行分割 187 set iskeyword+=_,$,@,%,#,- 188 "字符间插入的像素行数目 189 set wildmenu 190 "在被分割的窗口间显示空白,便于阅读 191 set fillchars=vert: ,stl: ,stlnc: