Chinaunix首页 | 论坛 | 博客
  • 博客访问: 21601
  • 博文数量: 9
  • 博客积分: 472
  • 博客等级: 下士
  • 技术积分: 105
  • 用 户 组: 普通用户
  • 注册时间: 2009-11-01 15:38
文章分类
文章存档

2011年(5)

2010年(2)

2009年(2)

我的朋友

分类:

2011-05-10 23:20:38

 if exists("*Lcpp") | finish | endif
set encoding=prc " chinese
set nocompatible " Use Vim settings, rather then Vi settings
" (much better!). This must be first, because it
" changes other options as a side effect!
set viminfo=%,'64,\"128,:128,n~/.viminfo
"set viminfo='20,\"50 " (vi) read/write a .viminfo file,
"   don't store more than 50 lines of registers
"set ch=2 " Make command line two lines high
set wrap " no wrap ???
set ruler " Show the position of the cursor.
set pastetoggle=
"set paste " it will reset tw wm ai si cin sts lisp
" ru revins sm fo!
"set mouse=n            "
set virtualedit=block " all, insert
set showcmd
set history=50
"set columns=80 " (co)
set comments=sr:/*,mb:*,ex:*/,b://,b:#,:%,b:XCOMM,n:>,fb:-,b:\" 
set complete=.,b,u,k,s,t,i " ĬèÏûóDk s
"set iskeyword+=-           " oü¶àóïÑÔÖDòÑŸ-ÔêDíê1óÃÖD»®Ïß×÷±äá¿ÃûáË.
set nobackup " Some option desactivate by default.
set hlsearch " (hls)
set incsearch
set cscopetag           " ???
set display= "lastline,uhex
"set linebreak
set showbreak=+>>>
set switchbuf=useopen
set showmatch " Show matching parenthese.
set backspace=2 " Default backspace like normal
set textwidth=78 " Terminal for 80 char so vim can play 79.
set statusline=~ " Set a statusbar
set ignorecase
set autoindent
set smartindent
set shiftround
"set clipboard="autoselect" ",exclude:cons\|linux"
set background=dark
set shiftwidth=8
"set dictionary=/usr/share/dict/words
set grepprg=grep\ -nH\ $*   " Set grep to alway generate a file-name.
set softtabstop=4       " it must place back of paste!
let c_comment_strings=1 " I like highlighting strings inside C comments

map   Q gq " Don't use Ex mode, use Q for formatting
map   ; :
"map  g :%
"map  v ~
map   :help

"map   a=strftime("%a, %d %b %Y %H:%M:%S %z")
" RFC822-conformant dates
map :tabn
map :tabp
nmap tn :tabn
nmap tp :tabp


map   :bp " Some macros to manage the buffer of vim
map   :bn
map   :bd
nnoremap :Tlist
"map   :set paste
"map   :set nopaste
map  
map   w " I know it's horrible for a vi master
cmap " but useful for newbies.
imap w
map   :if &modifiable && !&readonly && &modified 
\ :w :endif :bp 
imap :if &modifiable && !&readonly && &modified 
\ :w :endif :bp 

nmap :wqa

" To be able to use another command anyway, use the ":execute" command.
" Example (append the output of "ls" and jump to the first line):
"       :execute 'r !ls' | '[
vnoremap p :let current_reg = @"gvdi=current_reg

syntax on " Syntax highlighting only for enhanced-vi
  highlight Comment cterm=NONE
  filetype indent on
  filetype plugin on

command -range=% Ln :call LN(, )    " usr_40.txt
func LN(l1, l2)
    let l1 = a:l1
    let n = a:l2 - l1
    let l = strlen(n)
    let i = 0
    while i <= n
        let i  = i  + 1
        let space = strpart("        ", 0, l - strlen(i))
        exec l1 . "," . l1 . "s/^/" . space . i . " /"
        let l1 = l1 + 1
    endw
endf

"if has("autocmd")
  autocmd BufRead   * set fo=2croqlv wm=1 comments&
  autocmd BufRead   *.def set ft=conf
  autocmd BufRead   *.ld set ft=c
  autocmd BufRead   .letter set tw=72 fo=2tcrq
  autocmd BufEnter  .letter set dict=/usr/lib/dict/words
  autocmd BufLeave  .letter set dict=
  autocmd BufEnter  ?akefile* set include=^s\=include
  autocmd BufLeave  ?akefile* set include&
  autocmd BufRead   *.tex let  g:Tex_GotoError = 0
  autocmd BufRead   *.tex set fo=2tcroqwanmvM1 iskeyword+=:
\ sw=2 wm=1 comments&
  "autocmd BufRead *.sgml,*.tex  set fo=2tcroqwanmvM1 wm=1 comments&
  "autocmd BufRead *.fmh,*.txt   set fo=2tcroqwanmvM1 wm=1 comments&
  autocmd BufRead *.fmh set ft=c
  autocmd BufWritePre,FileWritePre * call LastMod()
  fun LastMod()
    if line("$") > 32
      let l = 32
    else
      let l = line("$")
    endif
    let wsp = "                             "
    let str = strftime("%a, %d %b %Y %H:%M:%S %z")
    exec "normal ms"
    exec "1," . l . "g/Last modified:/s/Last modified:.*/Last modified: " .
   \ str . strpart(wsp, 1, 42-strlen(str)-strlen($USER))
   \ . "by " . $USER . " #"
    exec "normal `s"
  endfun

  func SN(l1, l2, pat)
      let n = 1
      exec a:l1
      while search(a:pat, "W") > 0 && line(".") < a:l2
 exec "s/" . a:pat . "/" . n . "/"
 let n = n + 1
      endw
  endf

  "au! CursorHold *.[ch] nested exe "silent! ptag " . expand("")
  "au! CursorHold *.[ch] nested call PreviewWord()
  func PreviewWord()
    if &previewwindow " don't do this in the preview window
      return
    endif
    let w = expand("") " get the word under cursor
    if w != "" " if there is one ":ptag" to it
  
      " Delete any existing highlight before showing another tag
      silent! wincmd P " jump to preview window
      if &previewwindow " if we really get there...
        match none " delete existing highlight
        wincmd p " back to old window
      endif
  
      " Try displaying a matching tag for the word under the cursor
      let v:errmsg = ""
      exe "silent! ptag " . w
      if v:errmsg =~ "tag not found"
        return
      endif
  
      silent! wincmd P " jump to preview window
      if &previewwindow " if we really get there...
  if has("folding")
    silent! .foldopen " don't want a closed fold
  endif
  call search("$", "b") " to end of previous line
  let w = substitute(w, '\\', '\\\\', "")
  call search('\<\V' . w . '\>') " position cursor on match
  " Add a match highlight to the word at this position
        hi previewWord term=bold ctermbg=green guibg=green
  exe 'match previewWord "\%' . line(".") . 'l\%' . col(".") . 'c\k*"'
        wincmd p " back to old window
      endif
    endif
  endfun

augroup cprog " Set some sensible defaults for editing C-files
" Remove all cprog autocommands
  au!
  command Dc :call DCOMM()
  func DCOMM() " delete the block comment macro lines.
    exec "normal 1l"
    let l1 = searchpair('^\s*#\s*if\s\+\d\+', '', '^\s*#\s*endif', 'Wb')
    if l1 < 1
return
    endif
    exec "normal ]#"
    if getline(".") =~ '^\s*#\s*else'
return
    endif
    exec "normal dd" . l1 . "Gdd"
  endf

  command Rc :call RCOMM()
  func RCOMM() " reverse the block comment.
    exec "normal 1l"
    if searchpair('^\s*#\s*if\s\+\d\+', '', '^\s*#\s*enif', 'Wb') < 1
return
    endif
    exec '.s#\d\+#\=submatch(0)==0 ? 1 : 0#'
  endf

  command -range Co :call  COMM(, )
  func COMM(l1, l2) " add the MACRO comment around the block of C/Cpp code.
      exec a:l2+1 . "s%^%#endif /* comment by csduan */\%"
      exec a:l1 . "s%^%#if 0 /* comment by csduan */\%"
  endf

augroup END

augroup Binary
  au!
  au BufReadPre   *.bin,*.exe let &bin=1
  au BufReadPost  *.bin,*.exe if &bin | %!xxd
  au BufReadPost  *.bin,*.exe set ft=xxd | endif
  au BufWritePre  *.bin,*.exe if &bin | %!xxd -r
  au BufWritePre  *.bin,*.exe endif
  au BufWritePost *.bin,*.exe if &bin | %!xxd
  au BufWritePost *.bin,*.exe set nomod | endif
augroup END

" Transparent editing of gpg encrypted files.
" Placed Public Domain by Wouter Hanegraaff
" (asc support and sh -c"..." added by Osamu Aoki)
augroup aencrypted
    au!
    " First make sure nothing is written to ~/.viminfo while editing
    " an encrypted file.
    autocmd BufReadPre,FileReadPre      *.asc set viminfo=
    " We don't want a swap file, as it writes unencrypted data to disk
    autocmd BufReadPre,FileReadPre      *.asc set noswapfile
    " Switch to binary mode to read the encrypted file
    autocmd BufReadPre,FileReadPre      *.asc set bin
    autocmd BufReadPre,FileReadPre      *.asc let ch_save = &ch|set ch=2
    autocmd BufReadPost,FileReadPost    *.asc '[,']!sh -c "gpg --decrypt 2> /dev/null"
    " Switch to normal mode for editing
    autocmd BufReadPost,FileReadPost    *.asc set nobin
    autocmd BufReadPost,FileReadPost    *.asc let &ch = ch_save|unlet ch_save
    autocmd BufReadPost,FileReadPost    *.asc execute ":doautocmd BufReadPost " . expand("%:r")

    " Convert all text to encrypted text before writing
    autocmd BufWritePre,FileWritePre    *.asc   '[,']!sh -c "gpg --default-recipient-self -ae 2>/dev/null"
    " Undo the encryption so we are back in the normal text, directly
    " after the file has been written.
    autocmd BufWritePost,FileWritePost    *.asc   u
augroup END

augroup bencrypted
    au!
    " First make sure nothing is written to ~/.viminfo while editing
    " an encrypted file.
    autocmd BufReadPre,FileReadPre      *.gpg set viminfo=
    " We don't want a swap file, as it writes unencrypted data to disk
    autocmd BufReadPre,FileReadPre      *.gpg set noswapfile
    " Switch to binary mode to read the encrypted file
    autocmd BufReadPre,FileReadPre      *.gpg set bin
    autocmd BufReadPre,FileReadPre      *.gpg let ch_save = &ch|set ch=2
    autocmd BufReadPost,FileReadPost    *.gpg '[,']!sh -c "gpg --decrypt 2> /dev/null"
    " Switch to normal mode for editing
    autocmd BufReadPost,FileReadPost    *.gpg set nobin
    autocmd BufReadPost,FileReadPost    *.gpg let &ch = ch_save|unlet ch_save
    autocmd BufReadPost,FileReadPost    *.gpg execute ":doautocmd BufReadPost " . expand("%:r")

    " Convert all text to encrypted text before writing
    autocmd BufWritePre,FileWritePre    *.gpg   '[,']!sh -c "gpg --default-recipient-self -e 2>/dev/null"
    " Undo the encryption so we are back in the normal text, directly
    " after the file has been written.
    autocmd BufWritePost,FileWritePost    *.gpg   u
augroup END

  autocmd BufReadPost * if line("'\"") && line("'\"") <= line("$")
\ | exe "normal `\"" | endif

let g:manpageview_winopen="reuse"

syntax on

set nu
cs add cscope.out

highlight Comment ctermfg=green guifg=green
set background=dark

set ts=8
set sts=4
set noexpandtab

map ^F 
map X
map ? :!sdcv
map C :!cg
  autocmd BufEnter *.cpp,*.c,*.h map  0i//
  autocmd BufEnter *.cpp,*.c,*.h map  0xx

  autocmd BufEnter *.s map  0i!
  autocmd BufEnter *.s map  0x

  autocmd BufEnter [mM]ake[Ff]ile,*.sh  map  0i#
  autocmd BufEnter [mM]ake[Ff]ile,*.sh  map  0x

  autocmd BufEnter *vimrc,*.vim  map  0i"
  autocmd BufEnter *vimrc,*.vim  map  0x

set complete+=k "add dictionary complete
set dictionary=/usr/share/dic/words "set dictionary

set cindent shiftwidth=8 "set C language indent
filetype indent on

set statusline=%<%F%h%m%r%h%w%y\ %{&ff}\ %=\ lin:%l\,%L\ col:%c%V\ pos:%o\ ascii:%b\ %P  ls =2

"auto add comment above current line
command -nargs=+ Fo :call  Foo("")
fun! Foo(str) 
exec "normal O/*@D: ". a:str . " */"
endf
command -nargs=+ Fa :call  Faa("")
fun! Faa(str) 
exec "normal A/*@D: ". a:str . " */"
endf

if has("multi_byte")
    "set bomb
    set fileencodings=ucs-bom,utf-8,cp936,big5,euc-jp,euc-kr,latin1
    " 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, untested
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

阅读(696) | 评论(0) | 转发(0) |
0

上一篇: 有关9260 nand flash启动相关

下一篇:bashrc

给主人留下些什么吧!~~