自己用的vim配置文件 .vimrc

python和c可以自动缩进

  1 " filename:.vimrc
  2 " author:h3idan
  3 
  4 set nocompatible    "非兼容模式
  5 syntax on  "开启语法高亮
  6 set background=dark "背景色
  7 
  8 " 配色方案
  9 "color peaksea   
 10 color desert
 11 
 12 set filetype=python
 13 
 14 set modeline
 15 set ruler           "在左下角显示当前文件所在行
 16 set showcmd         "在状态栏显示命令
 17 set showmatch       "显示匹配的括号
 18 set ignorecase      "大小写无关匹配
 19 set smartcase       "只能匹配,即小写全匹配,大小写混合则严格匹配
 20 set hlsearch        "搜索时高亮显示
 21 "set incsearch       "增量搜索
 22 
 23 "set nohls           "搜索时随着输入立即定位,不知什么原因会关闭结果高亮
 24 
 25 set report=0        "显示修改次数
 26 set mouse=a         "控制台启用鼠标
 27 set number          "行号
 28 set nobackup        "无备份
 29 set fileencodings=ucs-bom,UTF-8,GBK,BIG5,latin1
 30 set fileencoding=UTF-8
 31 set fileformat=unix "换行使用unix方式
 32 set ambiwidth=double
 33 set noerrorbells    "不显示响铃
 34 set visualbell      "可视化铃声
 35 set foldmarker={,}  "缩进符号
 36 set foldmethod=indent   "缩进作为折叠标识
 37 set foldlevel=100   "不自动折叠
 38 set foldopen-=search    "搜索时不打开折叠
 39 set foldopen-=undo  "撤销时不打开折叠
 40 set updatecount=0   "不使用交换文件
 41 set magic           "使用正则时,除了$ . * ^以外的元字符都要加反斜线
 42 
 43 " "缩进定义
 44 set autoindent
 45 set smartindent
 46 set shiftwidth=4
 47 set tabstop=4
 48 set softtabstop=4
 49 set expandtab
 50 set smarttab
 51 
 52 set backspace=2     "退格键可以删除任何东西
 53 
 54 "显示TAB字符为<+++
 55 set list
 56 set list listchars=tab:<-
 57 
 58 " 窗口位置与大小
 59 "winpos 235 235
 60 set lines=35 columns=110
 61 
 62 "映射常用操作
 63 map [r :! python % <CR>
 64 map [o :! python -i % <CR>
 65 map [t :! rst2html.py % %<.html <CR>
 66 
 67 if has("gui_running")
 68     set lines=25
 69     set columns=80
 70     set lazyredraw  "延迟重绘
 71     set guioptions-=m   "不显示菜单
 72     set guioptions-=T   "不显示工具栏
 73     set guifont=consolas\ 10
 74 endif
 75 
 76 "<home>唤起自定义文件头
 77 map <home> <Esc>:call Mytitle()<CR><Esc>:$<Esc>o 
 78 function Mytitle()
 79          call setline(1,"#!/usr/bin/env python")
 80          call append(line("."),"# coding: utf-8")
 81          call append(line(".")+1,"")
 82          call append(line(".")+2,"#**********************************")
 83          call append(line(".")+3,"# author:   h3idan")
 84          call append(line(".")+4,"# datetime: ".strftime("%Y-%m-%d %H:%M"))
 85          call append(line(".")+5,"#**********************************")
 86          call append(line(".")+6,"")
 87          call append(line(".")+7,"")
 88 endf
 89 
 90 
 91 if has("autocmd")
 92 "回到上次文件打开所在行
 93     au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") 
 94     \| exe "normal g'\"" 
 95     \| endif
 96     "自动检测文件类型,并载入相关的规则文件
 97     filetype plugin on
 98     filetype indent on
 99     "智能缩进,使用4空格,使用全局的了
100     autocmd FileType python setlocal et | setlocal sta | setlocal sw=4
101     autocmd FileType c setlocal et | setlocal sta |    setlocal sw=4
102     autocmd FileType h setlocal et | setlocal sta |    setlocal sw=4
103 endif

linux下试用peaksea这个配色方案比较好看。peaksea需要去下载,然后放到vim下的color目录里面

 

 

posted on 2013-03-27 15:38  h3idan  阅读(272)  评论(0编辑  收藏  举报

导航