huozhenhua的个人博客分享 http://blog.sciencenet.cn/u/huozhenhua

博文

我的vimrc文件内容

已有 3249 次阅读 2011-11-11 09:59 |个人分类:Linux使用|系统分类:科研笔记|关键词:学者| better, always, Everything, defaults, insert

if v:lang =~ "utf8$" || v:lang =~ "UTF-8$"
   set fileencodings=ucs-bom,utf-8,latin1
endif

set nocompatible    " Use Vim defaults (much better!)
set bs=indent,eol,start        " allow backspacing over everything in insert mode
"set ai            " always set autoindenting on
"set backup        " keep a backup file
set viminfo='20,\"50    " read/write a .viminfo file, don't store more
            " than 50 lines of registers
set history=50        " keep 50 lines of command line history
set ruler        " show the cursor position all the time

" Only do this part when compiled with support for autocommands
if has("autocmd")
  augroup fedora
  autocmd!
  " In text files, always limit the width of text to 78 characters
  " autocmd BufRead *.txt set tw=78
  " When editing a file, always jump to the last cursor position
  autocmd BufReadPost *
  \ if line("'\"") > 0 && line ("'\"") <= line("$") |
  \   exe "normal! g'\"" |
  \ endif
  " don't write swapfile on most commonly used directories for NFS mounts or USB sticks
  autocmd BufNewFile,BufReadPre /media/*,/mnt/* set directory=~/tmp,/var/tmp,/tmp
  " start with spec file template
  autocmd BufNewFile *.spec 0r /usr/share/vim/vimfiles/template.spec
  augroup END
endif

if has("cscope") && filereadable("/usr/bin/cscope")
   set csprg=/usr/bin/cscope
   set csto=0
   set cst
   set nocsverb
   " add any database in current directory
   if filereadable("cscope.out")
      cs add cscope.out
   " else add database pointed to by environment
   elseif $CSCOPE_DB != ""
      cs add $CSCOPE_DB
   endif
   set csverb
endif

" Switch syntax highlighting on, when the terminal has colors
" Also switch on highlighting the last used search pattern.
if &t_Co > 2 || has("gui_running")
  syntax on
  set hlsearch
endif

filetype plugin on

if &term=="xterm"
     set t_Co=8
     set t_Sb=[4%dm
     set t_Sf=[3%dm
endif

" Don't wake up system with blinking cursor:
" http://www.linuxpowertop.org/known.php
let &guicursor = &guicursor . ",a:blinkon0"

" browsedir设置
set browsedir=buffer
 
" 自动格式化设置
filetype indent on
set autoindent
set smartindent

" history文件中需要记录的行数,恢复必须用到。
set history=1024
 

" 在处理未保存或只读文件的时候,弹出确认
set confirm
 
" 共享外部剪贴板
set clipboard+=unnamed
 
" 显示未完成命令
set showcmd
" 侦测文件类型
filetype on
 
" 载入文件类型插件
filetype plugin on
 
" 为特定文件类型载入相关缩进文件
filetype indent on
 
" 保存全局变量
set viminfo+=!
 
" 带有如下符号的单词不要被换行分割
set iskeyword+=_,$,@,%,#,-
 
" 语法高亮
syntax on
 
" 设置不兼容模式
set nocp
 
" 设置鼠标支持
set mouse=a

" 保存窗口大小
set sessionoptions+=resize
 
" C++头文件识别
au BufEnter /usr/include/c++/* setf cpp
au BufEnter /usr/include/g++-3/* setf cpp
 
" GNU标准
au BufEnter /usr/* call GnuIndent()
 
" 显示行号
set number
 
" tab宽度
set tabstop=4
set cindent shiftwidth=4
set autoindent shiftwidth=4
 
" C/C++注释
set comments=://
 
" 修正自动C式样注释功能 <2005/07/16>
set comments=s1:/*,mb:*,ex0:/
 
" 增强检索功能
set tags=./tags,./../tags,./**/tags
 
" 命令行补全
set wildmenu
" 自动补全括号,包括大括号
:inoremap ( ()<ESC>i
:inoremap ) <c-r>=ClosePair(')')<CR>
:inoremap { {}<ESC>i
:inoremap } <c-r>=ClosePair('}')<CR>
:inoremap [ []<ESC>i
:inoremap ] <c-r>=ClosePair(']')<CR>
:inoremap < <><ESC>i
:inoremap > <c-r>=ClosePair('>')<CR>

" 打开文件时,总是跳到退出之前的光标处
autocmd BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\   exe "normal! g`\"" |
\ endif
 
" 用浅色高亮当前行
if has("gui_running")
    autocmd InsertLeave * se nocul
    autocmd InsertEnter * se cul
endif
 
filetype plugin on      "允许使用ftplugin目录下的文件类型特定脚本
filetype indent on      "允许使用indent目录下的文件类型缩进
 
" 设置自动粘贴功能。
set pastetoggle=<F3>
 
" 设置以缩进的方式自动折叠和设置快捷方式
set foldmethod=indent
 
" map <F3> zO " 打开折叠
map <F4> zc " 关闭折叠
map <F5> zR    " 打开所有折叠
map <F6> zM    " 关闭所有折叠


 " 使用 murphy 调色板
colo torte

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

" 隐藏掉菜单和工具条。
set guioptions-=m
set guioptions-=T
map <silent> <F2> :if &guioptions =~# 'T' <Bar>
        \set guioptions-=T <Bar>
        \set guioptions-=m <bar>
    \else <Bar>
        \set guioptions+=T <Bar>
        \set guioptions+=m <Bar>
    \endif<CR>
 
" 标签页设置
if has("gui_running")
    set showtabline=2
    map! tn tabnew
    nmap <C-c> :tabclose<CR>
endif
 
" 标签页只显示文件名
function ShortTabLabel ()
    let bufnrlist = tabpagebuflist (v:lnum)
    let label = bufname (bufnrlist[tabpagewinnr (v:lnum) -1])
    let filename = fnamemodify (label, ':t')
    return filename
endfunction
 
set guitablabel=%{ShortTabLabel()}
 
" 使回格键(backspace)正常处理indent, eol, start等
set backspace=eol,start,indent
 
" 允许backspace和光标键跨越行边界
" set whichwrap+=<,>,h,l
 
" 可以在buffer的任何地方使用鼠标(类似office中在工作区双击鼠标定位)
set mouse=a
set selection=exclusive
set selectmode=mouse,key
 
" 启动的时候不显示那个援助索马里儿童的提示
set shortmess=atI
 
" 通过使用: commands命令,告诉我们文件的哪一行被改变过
set report=0
 
" 不让vim发出讨厌的滴滴声
set noerrorbells
 
" 在被分割的窗口间显示空白,便于阅读
set fillchars=vert:\ ,stl:\ ,stlnc:\
 
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"                              搜索和匹配                                      "
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 高亮显示匹配的括号
set showmatch
 
" 匹配括号高亮的时间(单位是十分之一秒)
set matchtime=3
 
" 在搜索的时候忽略大小写
set ignorecase
 
" 不要高亮被搜索的句子(phrases)
" set nohlsearch
 
" 在搜索时,输入的词句的逐字符高亮(类似firefox的搜索)
set incsearch
 
" 输入:set list命令是应该显示些啥?
set listchars=tab:\|\ ,trail:.,extends:>,precedes:<,eol:$
" Tab补全时忽略这些忽略这些
set wildignore=*.o,*.obj,*.bak,*.exe
" 光标移动到buffer的顶部和底部时保持3行距离
set scrolloff=3
 
"搜索出之后高亮关键词
set hlsearch
 
nmap <silent> <leader><cr> :noh<cr>
 
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"                              CTags的设定                                     "
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set tags=tags;
" 按照名称排序
let Tlist_Sort_Type = "name"
 
" 在右侧显示窗口
let Tlist_Use_Right_Window = 1
 
" 压缩方式
let Tlist_Compart_Format = 1
 
" 如果只有一个buffer,kill窗口也kill掉buffer
let Tlist_Exist_OnlyWindow = 1
 
" 不要关闭其他文件的tags
let Tlist_File_Fold_Auto_Close = 0
 
" 不要显示折叠树
let Tlist_Enable_Fold_Column = 0



https://m.sciencenet.cn/blog-623402-506849.html

上一篇:Fedora15 with Gnome3
下一篇:C++ Binary File I/O

0

该博文允许注册用户评论 请点击登录 评论 (0 个评论)

数据加载中...

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-6-3 14:50

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部