to myself 的分类学习日志

做自己想做的事
posts - 232, comments - 6, trackbacks - 0, articles - 0

Linux工具的配置

Posted on 2010-09-18 17:44 kongkongzi 阅读(215) 评论(0)  编辑 收藏 引用 所属分类: linux
vim的配置:
/etc/vimrc

if v:lang =~ "utf8$" || v:lang =~ "UTF-8$"
   set fileencodings
=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")
  
" 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
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

“双引号开始的行为注释行,下同 

“去掉讨厌的有关vi一致性模式,避免以前版本的一些bug和局限 

set nocompatible 

“显示行号 

set nummber 

“检测文件的类型 

filetype on 

“记录历史的行数 

set history
=1000 

“背景使用黑色 

set background
=dark 

“语法高亮度显示 

syntax on 



“下面两行在进行编写代码时,在格式对起上很有用; 

“第一行,vim使用自动对起,也就是把当前行的对起格式应用到下一行; 

“第二行,依据上面的对起格式,智能的选择对起方式,对于类似C语言编 

“写上很有用 

set autoindent 
set smartindent 

“第一行设置tab键为4个空格,第二行设置当行之间交错时使用4个空格 

set tabstop
=4 
set shiftwidth
=4 

“设置匹配模式,类似当输入一个左括号时会匹配相应的那个右括号 

set showmatch 

“去除vim的GUI版本中的toolbar 

set guioptions
-=

“当vim进行编辑时,如果命令错误,会发出一个响声,该设置去掉响声 

set vb t_vb
= 

“在编辑过程中,在右下角显示光标位置的状态行 

set ruler 

“默认情况下,寻找匹配是高亮度显示的,该设置关闭高亮显示 

set nohls 

“查询时非常方便,如要查找book单词,当输入到
/b时,会自动找到第一 

“个b开头的单词,当输入到
/bo时,会自动找到第一个bo开头的单词,依 

“次类推,进行查找时,使用此设置会快速找到答案,当你找要匹配的单词 

“时,别忘记回车 

set incsearch 

“修改一个文件后,自动进行备份,备份的文件名为原文件名加“
~“后缀 

if has(“vms”) 

set nobackup 

else 

set backup 

endif 

" An example for a vimrc file.
"
" Maintainer:    Bram Moolenaar <Bram@vim.org>
" Last change:    2002 Sep 19
"
" To use it, copy it to
"     for Unix and OS/2:  ~/.vimrc
"          for Amiga:  s:.vimrc
"  for MS-DOS and Win32:  $VIM\_vimrc
"        for OpenVMS:  sys$login:.vimrc

" When started as "evim", evim.vim will already have done these settings.

"set path+=c:/prog/include

set nocp
filetype plugin on

if v:progname =~? "evim"
  finish
endif
set guifont
=Bitstream\ Vera\ Sans\ Mono\ 11
so 
$VIMRUNTIME/delmenu.vim
so 
$VIMRUNTIME/menu.vim


set tags
=./tags

set tabstop
=4
set shiftwidth
=4

" Use Vim settings, rather then Vi settings (much better!).
" This must be first, because it changes other options as a side effect.
set nocompatible

" allow backspacing over everything in insert mode
set backspace=indent,eol,start

"if has("vms")
"  set nobackup        " do not keep a backup file, use versions instead
"else
"  set backup        " keep a backup file
"endif
set history
=50        " keep 50 lines of command line history
set ruler        
" show the cursor position all the time
set showcmd        
" display incomplete commands
set incsearch        
" do incremental searching

" For Win32 GUI: remove 't' flag from 'guioptions': no tearoff menu entries
" let &guioptions = substitute(&guioptions, "t", "", "g")

" Don't use Ex mode, use Q for formatting
map Q gq

" This is an alternative that also works in block mode, but the deleted
" text is lost and it only works for putting the current register.
"vnoremap p "_dp

" 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
colorscheme desert
set enc=utf-8
set fenc=utf-8
set fencs=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936

""Encoding settings
if has(
"multi_byte")
    
" Set fileencoding priority
    
if getfsize(expand("%")) > 0
         set fileencodings
=ucs-bom,utf-8,cp936,big5,euc-jp,euc-kr,latin1
    
else
         set fileencodings
=cp936,big5,euc-jp,euc-kr,latin1
    endif
    
" CJK environment detection and corresponding setting
    if v:lang =~ 
"^zh_CN"
         
" Use cp936 to support GBK, euc-cn == gb2312
         set encoding
=cp936
         set termencoding
=cp936
         set fileencoding
=cp936
    elseif v
:lang =~ "^zh_TW"
         
" cp950, big5 or euc-tw
         
" Are they equal to each other?
         set encoding
=big5
         set termencoding
=big5
         set fileencoding
=big5
     elseif v
:lang =~ "^ko"
         
" Copied from someone's dotfile, untested
         set encoding=euc-kr
         set termencoding=euc-kr
         set fileencoding=euc-kr
     elseif v:lang =~ 
"^ja_JP"
         
" Copied from someone's dotfile, unteste
         set encoding=euc-jp
         set termencoding=euc-jp
         set fileencoding=euc-jp
     endif
     " Detect UTF-8 locale, and replace CJK setting if needed
     if v:lang =~ "utf8$" || v:lang =~ "UTF-8$"
         set encoding=utf-8
         set termencoding=utf-8
         set fileencoding=utf-8
     endif
else
     "echoerr "Sorry, this version of (g)vim was not compiled with multi_byte"
endif

set path+=../include/
set path+=/Project/**/include/
"set syn=cpp

" Only do this part when compiled with support for autocommands.
if has("autocmd")

  " Enable file type detection.
  " Use the default filetype settings, so that mail gets 
'tw' set to 72,
  " 
'cindent' is on in C files, etc.
  " Also load indent files, to automatically do language-dependent indenting.
  filetype plugin indent on

  " Put these in an autocmd group, so that we can delete them easily.
  augroup vimrcEx
  au!

  " For all text files set 
'textwidth' to 78 characters.
  autocmd FileType text setlocal textwidth=78

  " When editing a file, always jump to the last known cursor position.
  " Don
'do it when the position is invalid or when inside an event handler
  
" (happens when dropping a file on gvim).
  autocmd BufReadPost *
    \ if line(
"'\"") > 0 && line("'\""<= line("$"|
    
\   exe "normal g`\"" |
    \ endif

  augroup END

else

  set autoindent        
" always set autoindenting on

endif 
" has("autocmd")
set number


map <C-F12> :!ctags -R -I --c++-kinds=+p --fields=+iaS --extra=+q .<CR>

if has(
"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
set cscopetag
set cscopequickfix=s-,g-,c-,d-,t-,e-,f-,i-
endif

vim的智能补全:
这里我们采用omni补全办法。
下载OmniCppComplete插件:http://www.vim.org/scripts/script.php?script_id=1520

Omni利用了工具ctags:
ctags -R -I --c++-kinds=+p --fields=+iaS --extra=+q .

vim相关配置文件:
/usr/ect/vim/
/usr/share/vim/
~/.vim

vim实现C++代码的智能补全功能:
c++的头文件:/usr/include/c++/4.4