1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
| "自动缩进的空格数 set shiftwidth=4 "关闭vi兼容模式 set nocompatible "显示行号 set number "打开状态栏标尺 set ruler "退格键删除四个空格 set softtabstop=4 "tab长度为4 set tabstop=4 set expandtab "设置自动缩进 set autoindent "覆盖文件时不备份 set nobackup " 禁止生成临时文件 set noswapfile "搜索时忽略大小写 set ignorecase smartcase "输入内容时开始搜索 set incsearch "高亮显示搜索结果 set hlsearch "关闭错误信息响铃 set noerrorbells "关闭使用可视响铃代替呼叫 set novisualbell "置空错误铃声的终端代码 set t_vb= "set showmatch " 插入括号时,短暂地跳转到匹配的对应括号 "set matchtime=2 " 短暂跳转到匹配括号的时间 "设置魔术 set magic "开启新行时使用智能自动缩进 set smartindent "不设定在插入状态无法用退格键和 Delete 键删除回车符 set backspace=indent,eol,start "显示状态栏 (默认值为 1, 无法显示状态栏) set laststatus=2 "设定命令行的行数为 1 set cmdheight=1 "高亮显示匹配的括号 set showmatch "匹配括号高亮的时间(单位是十分之一秒) set matchtime=5 "与windows贡献剪切板 set clipboard+=unnamed "文件类型检测 filetype on "不同文件类型采用不同缩进 filetype indent on "载入文件类型插件 filetype plugin on "语法高亮 syntax on " 设置当文件被改动时自动载入 set autoread "粘贴时保持格式 "set paste "设定默认解码 set fenc=utf-8 set fencs=utf-8,usc-bom,euc-jp,gb18030,gbk,gb2312,cp936 "设定编码 set enc=utf-8 set fileencodings=ucs-bom,utf-8,chinese set langmenu=zh_CN.UTF-8 language message en_US.UTF-8 source $VIMRUNTIME/delmenu.vim source $VIMRUNTIME/menu.vim
if version >= 603 set helplang=cn set encoding=utf-8 endif
" 状态栏配置 function! File_size(f) let l:size = getfsize(expand(a:f)) if l:size == 0 || l:size == -1 || l:size == -2 return '' endif if l:size < 1024 return l:size.' bytes' elseif l:size < 1024*1024 return printf('%.1f', l:size/1024.0).'KB' elseif l:size < 1024*1024*1024 return printf('%.1f', l:size/1024.0/1024.0) . 'MB' else return printf('%.1f', l:size/1024.0/1024.0/1024.0) . 'GB' endif endfunction set statusline=%F%m%r%h%w\ [%{&ff}]\ [%Y]\ [ASCII=\%03.3b]\ [HEX=\%02.2B]\ [POS=%04l,%04v,%p%%]\ [LEN=%L]\ [%{File_size(@%)}]\ [%{''.(&fenc!=''?&fenc:&enc).''}]
"修改文件后自动更新必要信息 autocmd FileType markdown autocmd BufWritePre,FileWritePre <buffer> call FileUpdate() function! FileUpdate() if &filetype == 'markdown' if line("$") > 5 let l = 5 else let l = line("$") endif exe "1," . l . "g/updated: /s/updated: .*/updated: " .strftime("%Y-%m-%d %H:%M") exe "1," . l . "g/title: /s/title: .*/title: " .expand("%:r") endif endfunction "新建文件后,自动定位到文件末尾 "autocmd BufNewFile * normal G " 新建py文件时自动添加头部 autocmd BufNewFile *.py,*.md exec ":call NewFile()" function! NewFile() if &filetype == 'python' call setline(1,"# -*- coding:utf-8 -*-") call append(line(".")," ") call append(line(".")+1,"# Author dream10201") call append(line(".")+2,"# E-mail [email protected]") call append(line(".")+3,"# Created Time ".strftime("%Y/%m/%d",localtime())) call append(line(".")+4,"") endif if &filetype == 'markdown' call setline(1,"---") call append(line("."),"title: ".expand("%:r")) call append(line(".")+1,"date: ".strftime("%Y-%m-%d %H:%M",localtime())) call append(line(".")+2,"updated: ".strftime("%Y-%m-%d %H:%M",localtime())) call append(line(".")+3,"tags: ") call append(line(".")+4,"categories: ") call append(line(".")+5,"---") call append(line(".")+6,"") call append(line(".")+7,"<!--more-->") call append(line(".")+8,"") endif " 定位到末尾 normal G endfunction
|