vimrc配置文件_version1.0_+pathogen, taglist, wordcomplete插件说明

July 13, 2013
Vim

为了表示对Ruchee的感谢,首先这是Ruchee的个人网站:http://www.ruchee.com/index.html,他的以前很多的代码都放到Git里面了,里面有链接。 看了整整一天,刚开始学习vim的时候就是用的Ruchee的vimrc脚本,现在终于可以自己写一点了,又认真看了一下Ruchee原来的脚本,虽然还有一些不太懂,但还是赶脚好腻害的样子。 然后自己又加了一点自己东西:——适用于mac, linux平台


"Copyright 2013 Xueyang Liu, all rights reserved.
"www.cnblogs.com/liuxueyang/
"Hunan University


" ********************SET********************
color lucius
"color desert
set nocompatible
set guifont=Monaco:h16
set lines=30 columns=94
set nu numberwidth=5
set cindent
set ai
set tabstop=2
set shiftwidth=2 
set mouse=a
set autochdir
se hlsearch incsearch 
se ruler
set laststatus=2
set cmdheight=2
syntax on
syntax enable
filetype plugin indent on
filetype indent on
filetype plugin on
"filetype on
"set bg=dark

" ********************MAP********************
let mapleader=","
noremap <space> ve
nnoremap <leader>ev :vsplit $MYVIMRC<cr>
nnoremap <leader>sv :source $MYVIMRC<cr>
nnoremap wt :WMToggle<cr> 
nnoremap <c-t> :NERDTree<cr>
nnoremap <c-a> :Tlist<cr>
"在某个单词上加上引号,括号
nnoremap <leader>" viw<esc>a"<esc>hbi"<esc>lel
nnoremap <leader>' viw<esc>a'<esc>hbi'<esc>lel
nnoremap <leader>< viw<esc>a><esc>'<i<<esc>lw
"~~~~~~~~~~~~~~~大风歌~~~~~~~~~~~~~~~
vnoremap \ U
inoremap <c-d> <esc>ddi
inoremap <c-u> <esc>veU
inoremap jk <esc>
inoremap <esc> <nop>
"括号,引号自动补全
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 ' ''<esc>i
onoremap p i(
onoremap b /return<cr>

" ********************OTHER********************
iabbrev @@ www.cnblogs.com/liuxueyang/
iabbrev ccopy Copyright 2013 Xueyang Liu, all rights reserved.
autocmd BufWritePre *.html :normal gg=G
"下面这些autocmd还没有学会=_=
"autocmd FileType C++ nnoremap <buffer> <localleader>c I//<esc>
"autocmd FileType javascript nnoremap <buffer> <localleader>c I//<esc>
"autocmd FileType javascript :iabbrev <buffer> iff if()<left>
"autocmd FileType python nnoremap <buffer> <localleader>c I#<esc>
"autocmd FileType python : iabbrev <buffer> iff if:<left>
"echo ">^.^<"

" ********************编译 && 运行********************
" Compile
func! CompileCode()
    exec "w"
    if &filetype == "c"
        exec "!gcc -Wall -std=c99 %<.c -o %<"
    elseif &filetype == "cpp"
        exec "!g++ -Wall -std=c++98 %<.cpp -o %<"
    elseif &filetype == "python"
        exec "!python %<.py"
    endif
endfunc
"Run
func! RunCode()
    exec "w"
    if &filetype == "c" || &filetype == "cpp"
        exec "! ./%<"
    elseif &filetype == "python"
        exec "!python %<.py"
    endif
endfunc
"<c-c> OneKey ComplieAndSave
nnoremap <c-c> :call CompileCode()<cr>
inoremap <c-c> <esc>:call CompileCode()<cr>
vnoremap <c-c> <esc>:call CompileCode()<cr>
"<c-r> OneKey RunAndSave
nnoremap <c-r> :call RunCode()<cr>
inoremap <c-r> <esc>:call RunCode()<cr>
vnoremap <c-r> <esc>:call RunCode()<cr>
"pathogen{
execute pathogen#infect()
call pathogen#infect()
"}
"taglist{
    let Tlist_Show_One_File = 1            "只显示当前文件的taglist,默认是显示多个
    let Tlist_Exit_OnlyWindow = 1          "如果taglist是最后一个窗口,则退出vim
    let Tlist_Use_Right_Window = 1         "在右侧窗口中显示taglist
    let Tlist_GainFocus_On_ToggleOpen = 1  "打开taglist时,光标保留在taglist窗口
    let Tlist_Ctags_Cmd='/opt/local/bin/ctags'  "设置ctags命令的位置
    nnoremap <leader>tl : Tlist<CR>        "设置关闭和打开taglist窗口的快捷键
"}
autocmd BufEnter * call DoWordComplete()

主要部分是抄的Ruchee的=_=

comments powered by Disqus