linux vim 配置

# vim /etc/vimrc   
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"


"===============本人添加==========================
syntax on 
"设置(软)制表符宽度为4
set tabstop=4
set softtabstop=4
"设置缩进的空格数为4
set shiftwidth=4 
"设置自动缩进
set autoindent 
set cindent
set cinoptions={0,1s,t0,n-2,p2s,(03s,=.5s,>1s,=1s,:1s
set nu

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

"使vi兼容windows的中文 
set fencs=utf-8,ucs-bom,euc-jp,gb18030,gbk,gb2312,cp936
"TAb键自动补全函数功能、
function! CleverTab() 
  if strpart( getline('.'), 0, col('.')-1 ) =~'^\s*$' 
      return "\<Tab>" 
  else 
      return "\<C-N>" 
endfunction 
inoremap <Tab> <C-R>=CleverTab()<CR> 

set nu
set autoindent 
set mouse=a 
set tabstop=4 
set syntax=make 
set incsearch 
set nocompatible 
set backspace=indent,eol,start  
set history=100
set ruler 
set showcmd 
filetype plugin indent on 
set nowrap 
set sidescroll=5
set whichwrap=b,s,<,>,[,]
set list 
set listchars=tab:>-,trail:-
" 2011-3-19 添加
syntax enable
syntax on
set helplang=cn
set foldmethod=marker
filetype plugin indent on
set completeopt=longest,menu
let g:SuperTabRetainCompletionType=2
let g:SuperTabDefaultCompletionType="<C-X><C-O>"

"=======================================================
".vimrc
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" General
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"For ctags, then it can find the 'tags' file even not in current directory
set tags=tags;/
"Get out of VI's compatible mode..
set nocompatible
"Sets how many lines of history VIM har to remember
set history=400
"Set to auto read when a file is changed from the outside
set autoread
"Have the mouse enabled all the time:
"when you need to copy from vim, maybe you have to ':set mouse=' first
set mouse=a
"""""""""""""""""""""""""""""""""""""
" Colors and Fonts
"""""""""""""""""""""""""""""""""""""
"Enable syntax highlight
syntax enable
"set colorscheme
colorscheme elflord
"endif
"""""""""""""""""""""""""""""""""""""
" VIM userinterface
"""""""""""""""""""""""""""""""""""""
"Set 7 lines to the curors away from the border- when moving vertical..
set so=7
"Turn on WiLd menu
set wildmenu
"Always show current position
set ruler
"The commandbar is 2 high
set cmdheight=2
"Show line number
set nu
"Set backspace
set backspace=eol,start,indent
"Bbackspace and cursor keys wrap to
set whichwrap+=<,>,h,l
"show matching bracets
set showmatch
"How many tenths of a second to blink
set mat=2
"Highlight search things
set hlsearch
"imediately show the search result
set is
"""""""""""""""""""""""""""""""""""""
" Folding
"""""""""""""""""""""""""""""""""""""
"Enable folding, I find it very useful
set nofen
set fdl=0
"""""""""""""""""""""""""""""""""""""
" Text options
"""""""""""""""""""""""""""""""""""""
set expandtab
set shiftwidth=2
set ambiwidth=double
set smarttab
"Set Tab=4 spaces
set ts=4
set lbr
set tw=500
set selection=inclusive
   """"""""""""""""""""""""""""""
   " Indent
   """"""""""""""""""""""""""""""
   "Auto indent
   set ai
   "Set auto indent width = 4 spaces
   set sw=4
   "Smart indet
   set si
   "C-style indenting
   set cindent "usage: select codes, press '=' key, the codes will autoindenting
   "Wrap lines
   set wrap
"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
"""""""""""""""""""""""""""""""""""""
"plugins
"""""""""""""""""""""""""""""""""""""
" Tlist
if &diff
let Tlist_Auto_Open=0 "don't auto pen when compare two files
else
let Tlist_Auto_Open=1 "auto pen Tlist when open a file
endif
"set taglist window in right, delete the following line if you don't like
let Tlist_Use_Right_Window=0
let Tlist_Auto_Update=1 
let Tlist_File_Fold_Auto_Close=1
"auto close Tlist when exiting file.
let Tlist_Exit_OnlyWindow = 1 
"nmap <F7> :copen<CR>
"nmap <F6> :cclose<CR>
"let Tlist_Use_Right_Window = 1     "使用右侧窗口
let Tlist_File_Fold_Auto_Close = 1  "自动关闭
let Tlist_Show_One_File = 1      "一次只显示一个文件中的信息
let Tlist_Auto_Open = 0          "设置打开文件自动打开
map <F4> : Tlist<CR>     "设置快捷键<F4>

"在左侧打开taglist窗口
let Tlist_Use_Right_Window=0
"自动折叠当前非编辑文件的方法列表
let Tlist_File_Fold_Auto_Close=1
let Tlist_WinWidth = 18
"Vim 复制粘帖格式错乱问题的解决办法
set pastetoggle=<F9>


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值