我的vim linux下配置

let g:isWin=0
let g:isMac=0
let g:isLinux=0


if(has("win32") || has("win95") || has("win64") || has("win16"))
    let g:isWin=1
elseif(has("unix"))
    let s:uname = system("uname -s")
    "string compare in vim use =~
    "http://unix.stackexchange.com/questions/40047/vim-script-check-running-platform
    if s:uname =~ "Darwin"
        let g:isMac=1
    endif
    if(has("x11"))
        let g:isLinux=1
    endif
endif


set helplang=cn "中文help
set mouse=v


map <silent> <C-s> :w<cr>
imap <silent> <C-s> <esc>:w<cr>"


map <F2> :NERDTreeToggle<CR>
let g:NERDTree_title = "[NERD Tree]"
let NERDTreeShowBookmarks=1 "一直显示书签
let NERDTreeChDirMode=2 "
            
let g:neocomplcache_enable_at_startup = 1


set makeprg=gcc\ -Wall\ -o%.o\ %


" Encoding related
set fileencodings=utf-8,gb2312,gbk,gb18030
set termencoding=utf-8


set nocompatible
set autoread<
syntax enable
set hlsearch
set wrap
set nu
set ai ts=4 sts=4 et sw=4


if has("gui_running")
colorscheme desertEx
else
"colorscheme desert
 colorscheme  wombat256mod "256暗色有看着比较舒服


endif

set t_Co=256 "要使用wobat256mod必须用256色

set cpt=.,w,b
set ignorecase

set wildmenu
set smarttab

map! <c-tab> <tab>

set nobackup
set noswapfile

let Tlist_Ctags_Cmd='ctags' "因为我们放在环境变量里,所以可以直接执行
let Tlist_Show_One_File=1
let Tlist_WinHeight=25
let Tlist_Use_Right_Window=1
let Tlist_File_Fold_Auto_Close=1
"tasklist
""map T :TaskList<CR>
nmap <silent> <F4> :TlistToggle<CR>

map <silent> <C-n> :tabnew<cr>
map <silent> <C-a> gg0vG$<cr>
map <silent> qq :tabclose<cr>
map <silent> qb :bd<cr>

let mapleader=","
map <silent> <leader>l :call NERDComment(0, "toggle")<cr> 
map <silent> <leader>k :call NERDComment(0, "sexy")<cr> 
map <silent> <leader>p :tabp<cr> 
map <silent> <leader>n :tabn<cr> 
map <silent> <leader>e :edit ~/.vimrc<cr> 
map <silent> <leader>1 gg<cr> 
map <silent> <leader>g GG<cr> 


" change set nonu map
map <leader>tn :call Toggle_Number()<cr>
function! Toggle_Number()
    if !exists("b:togglenum")
        let b:togglenum=1
    endif
    if b:togglenum==1
        execute "set nonu"
        let b:togglenum=0
    else
        let b:togglenum=1
        execute "set nu"
    endif
endfunction




"Key map for FuzzyFinder                                                       
let mapleader=","
map <leader>ff :FufFile<cr>
map <leader>fb :FufBuffer<cr>




" CTRL-X and SHIFT-Del are Cut
vnoremap <C-X> "+x
vnoremap <S-Del> "+x


" CTRL-C and CTRL-Insert are Copy
" On OSX
if g:isMac == 1
    vmap <C-c> y:call system("pbcopy", getreg("\""))<CR>
    nmap <C-v> :call setreg("\"",system("pbpaste"))<CR>p>))>>))>
    vmap "+y :w !pbcopy<CR><CR> 
    nmap "+p :r !pbpaste<CR><CR>
else
    " CTRL-V and SHIFT-Insert are Paste
    "map <C-V> "+gP
    "cmap <C-V> <C-R>+
endif


"vnoremap <C-Insert> "+y


" Use CTRL-Q to do what CTRL-V used to do
noremap <leader>v <C-V>


"  find next line error
nmap <leader>cn :cn<cr>
nmap <leader>cp :cp<cr>
nmap <leader>cw :cw 10<cr> 


inoremap ( ()<ESC>i
inoremap [ []<ESC>i
inoremap { {}<ESC>i
inoremap < <><ESC>i


"file type suppport
au BufRead,BufNewFile,BufEnter,TabEnter *.coffee call SetFileTypCoffee()                                                              
function! SetFileTypCoffee()
    set filetype=coffee
    nmap <F5> :!coffee %<CR>
    nmap <F6> :!coffee -p %<CR>
endfunction


"auto command
au BufRead,BufNewFile,BufEnter,TabEnter * lcd %:p:h
au BufReadPost,BufNewFile * call Add_Tags()
function! Add_Tags()
    if expand("%:p:h") !=getcwd()
        echohl WarningMsg | echo "Fail to make! This file is not in the current dir! Press <F7> to redirect to the dir of this file." | echohl None
        return
    endif
    let srcdir=expand("%:p:h")
    let i=0
    while isdirectory(srcdir) 
        if i>3
            break
        endif
        if filereadable(srcdir . "/tags")
            let file=srcdir."/tags"
            "echo printf("set tags %s", file)
            if i==0
                execute "set tags=".file
            else
                execute "set tags+=".file
            endif
        endif
        let newdir=fnamemodify(srcdir,":p:h:h")
        "echo printf("newdir %s", newdir)
        if newdir != srcdir
            let srcdir=newdir
        else
            break
        endif
        let i=i+1
    endwhile
endfunction


"单个文件编译
map <F6> :call Do_OneFileMake()<CR>
function! Do_OneFileMake()
    if expand("%:p:h")!=getcwd()
        echohl WarningMsg | echo "Fail to make! This file is not in the current dir! Press <F7> to redirect to the dir of this file." | echohl None
        return
    endif
    let sourcefileename=expand("%:t")
    if (sourcefileename=="" || (&filetype!="cpp" && &filetype!="c"))
        echohl WarningMsg | echo "Fail to make! Please select the right file!" | echohl None
        return
    endif
    let deletedspacefilename=substitute(sourcefileename,' ','','g')
    if strlen(deletedspacefilename)!=strlen(sourcefileename)
        echohl WarningMsg | echo "Fail to make! Please delete the spaces in the filename!" | echohl None
        return
    endif
    if &filetype=="c"
        if g:isWin==1
            set makeprg=gcc\ -o\ %<.exe\ %
        else
            set makeprg=gcc\ -o\ %<\ %
        endif
    elseif &filetype=="cpp"
        if g:isWin==1
            set makeprg=g++\ -o\ %<.exe\ %
        else
            set makeprg=g++\ -o\ %<\ %
        endif
        "elseif &filetype=="cs"
        "set makeprg=csc\ \/nologo\ \/out:%<.exe\ %
    endif
    if(g:isWin==1)
        let outfilename=substitute(sourcefileename,'\(\.[^.]*\)' ,'.exe','g')
        let toexename=outfilename
    else
        let outfilename=substitute(sourcefileename,'\(\.[^.]*\)' ,'','g')
        let toexename=outfilename
    endif
    if filereadable(outfilename)
        if(g:isWin==1)
            let outdeletedsuccess=delete(getcwd()."\\".outfilename)
        else
            let outdeletedsuccess=delete("./".outfilename)
        endif
        if(outdeletedsuccess!=0)
            set makeprg=make
            echohl WarningMsg | echo "Fail to make! I cannot delete the ".outfilename | echohl None
            return
        endif
    endif
    execute "silent make"
    set makeprg=make
    execute "normal :"
    if filereadable(outfilename)
        if(g:isWin==1)
            execute "!".toexename
        else
            execute "!./".toexename
        endif
    endif
    execute "copen"
endfunction
"进行make的设置
"map <F6> :call Do_make()<CR>
"map <c-F6> :silent make clean<CR>
function! Do_make()
    set makeprg=make
    execute "silent make"
    execute "copen"
endfunction


" cscope
map <F12> :call Do_CsTag()<CR>
nmap <C-@>s :cs find s <C-R>=expand("<cword>")<CR><CR>:copen<CR>
nmap <C-@>g :cs find g <C-R>=expand("<cword>")<CR><CR>
nmap <C-@>c :cs find c <C-R>=expand("<cword>")<CR><CR>:copen<CR>
nmap <C-@>t :cs find t <C-R>=expand("<cword>")<CR><CR>:copen<CR>
nmap <C-@>e :cs find e <C-R>=expand("<cword>")<CR><CR>:copen<CR>
nmap <C-@>f :cs find f <C-R>=expand("<cfile>")<CR><CR>:copen<CR>
nmap <C-@>i :cs find i ^<C-R>=expand("<cfile>")<CR>$<CR>:copen<CR>
nmap <C-@>d :cs find d <C-R>=expand("<cword>")<CR><CR>:copen<CR>
function! Do_CsTag()
    let dir = getcwd()
    if filereadable("tags")
        if(g:isWin==1)
            let tagsdeleted=delete(dir."\\"."tags")
        else
            let tagsdeleted=delete("./"."tags")
        endif
        if(tagsdeleted!=0)
            echohl WarningMsg | echo "Fail to do tags! I cannot delete the tags" | echohl None
            return
        endif
    endif
    if has("cscope")
        silent! execute "cs kill -1"
    endif
    if filereadable("cscope.files")
        if(g:isWin==1)
            let csfilesdeleted=delete(dir."\\"."cscope.files")
        else
            let csfilesdeleted=delete("./"."cscope.files")
        endif
        if(csfilesdeleted!=0)
            echohl WarningMsg | echo "Fail to do cscope! I cannot delete the cscope.files" | echohl None
            return
        endif
    endif
    if filereadable("cscope.out")
        if(g:isWin==1)
            let csoutdeleted=delete(dir."\\"."cscope.out")
        else
            let csoutdeleted=delete("./"."cscope.out")
        endif
        if(csoutdeleted!=0)
            echohl WarningMsg | echo "Fail to do cscope! I cannot delete the cscope.out" | echohl None
            return
        endif
    endif
    if(executable('ctags'))
        "silent! execute "!ctags -R --c-types=+p --fields=+S *"
        silent! execute "!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q ."
    endif
    if(executable('cscope') && has("cscope") )
        if(g:isWin!=1)
            silent! execute "!find . -name '*.h' -o -name '*.c' -o -name '*.cpp' -o -name '*.java' -o -name '*.cs' > cscope.files"
        else
            silent! execute "!dir /s/b *.c,*.cpp,*.h,*.java,*.cs >> cscope.files"
        endif
        silent! execute "!cscope -b"
        execute "normal :"
        if filereadable("cscope.out")
            execute "cs add cscope.out"
        endif
    endif
endfunction


"
" """""""""""""""""""""""""""""""""""""""""""""""""""""""
" " vundle begin
" """""""""""""""""""""""""""""""""""""""""""""""""""""""
filetype off
" required!
"
"
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
"
"
" " let Vundle manage Vundle
Bundle 'gmarik/vundle'
"
"
" " vim-scripts repos
"
"
"Improved C++ STL syntax highlighting
Bundle 'STL-improved'
"
"
" " Displays tags in a window, ordered by class etc, i used it instead of
" taglist
Bundle 'majutsushi/tagbar'
"
"
Bundle 'autoload_cscope.vim'
Bundle 'CmdlineComplete'
Bundle 'xptemplate'
"
"
" " &nbsp;Ultimate auto completion system for Vim
Bundle 'neocomplcache'
"
"
" "Bundle 'Rip-Rip/clang_complete'
" "Bundle 'osyo-manga/neocomplcache-clang_complete'
"
"
Bundle 'genutils'
"Bundle 'lookupfile'
"
"
" " Fuzzy file, buffer, mru, tag, ... finder with regexp support.
" Bundle 'kien/ctrlp.vim'
"
"
" " Fast file navigation
" Bundle 'wincent/Command-T'
"
"
" " Preview the definition of variables or functions in a preview window
" Bundle 'autopreview'
"
"
" " Echo the function declaration in the command line for C/C++
" Bundle 'echofunc.vim'
"
"
Bundle 'L9'
Bundle 'FuzzyFinder'
Bundle 'grep.vim'
Bundle 'a.vim'
Bundle 'taglist.vim'
Bundle 'The-NERD-Commenter'
Bundle 'The-NERD-tree'


Bundle 'OmniCppComplete' 
Bundle 'wombat256.vim'


"
"
" " Under linux need exec 'dos2unix
" ~/.vim/bundle/QFixToggle/plugin/qfixtoggle.vim'
" Bundle 'QFixToggle'
"
"
" Bundle 'Color-Sampler-Pack'
" Bundle 'altercation/vim-colors-solarized'
" Bundle 'txt.vim'
" Bundle 'mru.vim'
" Bundle 'YankRing.vim'
" Bundle 'tpope/vim-surround.git'
" Bundle 'DoxygenToolkit.vim'
" Bundle 'headerGatesAdd.vim'
" Bundle 'ShowMarks'
" Bundle 'Lokaltog/vim-powerline'
"
"
" " Deal with pairs of punctuations such as (), [], {}, and so on
"Bundle 'kana/vim-smartinput'
"Bundle "MarcWeber/vim-addon-mw-utils"
"Bundle "tomtom/tlib_vim"
"Bundle "honza/snipmate-snippets" 不能使用


"Bundle "garbas/vim-snipmate"


"for coffeescript
Bundle 'kchmck/vim-coffee-script'


"
"
" " non github repos
" " ...
filetype plugin indent on " required!&nbsp;
" """""""""""""""""""""""""""""""""""""""""""""""""""""""
" " vundle end
" """""""""""""""""""""""""""""""""""""""""""""""""""""""
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值