-vimプロファイルコレクション

47551 ワード

自己転載:http://www.cnblogs.com/ma6174/archive/2011/12/10/2283393.html
1.F 5で直接コンパイルしてC、C++、javaコードとshellスクリプトを実行できます.「F 8」を押してC、C++コードのデバッグができます.
2.自動的にファイルヘッダを挿入し、C、C++ソースファイルを新規作成する時に、自動的にヘッダを挿入します.ファイル名、著者、連絡先、作成時間などを含み、読者は必要に応じて自分で変更できます.
3.「Ctrl+A」をフル選択してショートカットをコピーすると便利です.
4.「F 2」を押すと、コードの空行を直接に消去できます.
5.「F 3」は現在のディレクトリファイルを一覧表示し、ツリーファイルのディレクトリを開くことができます.
6.マウスの選択、方向キーの移動をサポートします.
7.コードが明るく、自動的にインデントされ、行番号が表示され、状態行が表示されます.
8.「Ctrl+P」を押すと自動的に補完できます.
9.[]、{}、()、''などは自動的に補完されます.
10.他の機能の読者は以下の文書を研究することができます.
 
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

"       

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

"set shortmess=atI   "                       

"winpos 5 5          "         

"set lines=40 columns=155    "         

"set nu              "       

set go=             "         

"color asmanian2     "         

set guifont=Courier_New:h10:cANSI   "       

"syntax on           "       

autocmd InsertLeave * se nocul  "           

autocmd InsertEnter * se cul    "           

"set ruler           "       

set showcmd         "

"set cmdheight=1     "    (     )   ,   1  

"set whichwrap+=<,>,h,l   "   backspace         (   )  

"set scrolloff=3     "      buffer         3     

set novisualbell    "     (   )  

set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [POS=%l,%v][%p%%]\ %{strftime(\"%d/%m/%y\ -\ %H:%M\")}   "          

set laststatus=1    "        (1),       (2)  

set foldenable      "       

set foldmethod=manual   "       

"set background=dark "       

set nocompatible  "       vi     ,         bug     

"       

if version >= 603

    set helplang=cn

    set encoding=utf-8

endif

"       

"colorscheme murphy

"   

"if (has("gui_running")) 

"   set guifont=Bitstream\ Vera\ Sans\ Mono\ 10 

"endif 


 
set fencs=utf-8,ucs-bom,shift-jis,gb18030,gbk,gb2312,cp936

set termencoding=utf-8

set encoding=utf-8

set fileencodings=ucs-bom,utf-8,cp936

set fileencoding=utf-8



"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

"""""     """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

"  .c,.h,.sh,.java  ,        

autocmd BufNewFile *.cpp,*.[ch],*.sh,*.java exec ":call SetTitle()" 

""    SetTitle,        

func SetTitle() 

    "       .sh   

    if &filetype == 'sh' 

        call setline(1,"\#########################################################################") 

        call append(line("."), "\# File Name: ".expand("%")) 

        call append(line(".")+1, "\# Author: ma6174") 

        call append(line(".")+2, "\# mail: [email protected]") 

        call append(line(".")+3, "\# Created Time: ".strftime("%c")) 

        call append(line(".")+4, "\#########################################################################") 

        call append(line(".")+5, "\#!/bin/bash") 

        call append(line(".")+6, "") 

    else 

        call setline(1, "/*************************************************************************") 

        call append(line("."), "    > File Name: ".expand("%")) 

        call append(line(".")+1, "    > Author: ma6174") 

        call append(line(".")+2, "    > Mail: [email protected] ") 

        call append(line(".")+3, "    > Created Time: ".strftime("%c")) 

        call append(line(".")+4, " ************************************************************************/") 

        call append(line(".")+5, "")

    endif

    if &filetype == 'cpp'

        call append(line(".")+6, "#include<iostream>")

        call append(line(".")+7, "using namespace std;")

        call append(line(".")+8, "")

    endif

    if &filetype == 'c'

        call append(line(".")+6, "#include<stdio.h>")

        call append(line(".")+7, "")

    endif

    "

    autocmd BufNewFile * normal G

endfunc 

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

"    

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""



nmap <leader>w :w!<cr>

nmap <leader>f :find<cr>



"     +   ctrl+a

map <C-A> ggVGY

map! <C-A> <Esc>ggVGY

map <F12> gg=G

"       Ctrl+c   

vmap <C-c> "+y

"     

nnoremap <F2> :g/^\s*$/d<CR> 

"      

nnoremap <C-F2> :vert diffsplit 

"      

map <M-F2> :tabnew<CR>  

"          

map <F3> :tabnew .<CR>  

"          

map <C-F3> \be  

"C,C++  F5    

map <F5> :call CompileRunGcc()<CR>

func! CompileRunGcc()

    exec "w"

    if &filetype == 'c'

        exec "!g++ % -o %<"

        exec "! ./%<"

    elseif &filetype == 'cpp'

        exec "!g++ % -o %<"

        exec "! ./%<"

    elseif &filetype == 'java' 

        exec "!javac %" 

        exec "!java %<"

    elseif &filetype == 'sh'

        :!./%

    endif

endfunc

"C,C++   

map <F8> :call Rungdb()<CR>

func! Rungdb()

    exec "w"

    exec "!g++ % -g -o %<"

    exec "!gdb ./%<"

endfunc

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

""    

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

"              

set autoread

" quickfix  

autocmd FileType c,cpp map <buffer> <leader><space> :w<cr>:make<cr>

"     

set completeopt=preview,menu 

"      

filetype plugin on

"       

set clipboard+=unnamed 

"      

set nobackup

"make   

:set makeprg=g++\ -Wall\ \ %

"    

set autowrite

set ruler                   "        

set cursorline              "        

set magic                   "     

set guioptions-=T           "      

set guioptions-=m           "      

"set statusline=\ %<%F[%1*%M%*%n%R%H]%=\ %y\ %0(%{&fileformat}\ %{&encoding}\ %c:%l/%L%)\

"            

set foldcolumn=0

set foldmethod=indent 

set foldlevel=3 

set foldenable              "     

"     vi     ,  vim   

set nocompatible

"     

set syntax=on

"            

set noeb

"

set confirm

"     

set autoindent

set cindent

" Tab    

set tabstop=4

"      4

set softtabstop=4

set shiftwidth=4

"           

set noexpandtab

"             

set smarttab

"     

set number

"      

set history=1000

"        

set nobackup

set noswapfile

"       

set ignorecase

"       

set hlsearch

set incsearch

"    

set gdefault

"    

set enc=utf-8

set fencs=utf-8,ucs-bom,shift-jis,gb18030,gbk,gb2312,cp936

"    

set langmenu=zh_CN.UTF-8

set helplang=cn

"           (         )

"set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [POS=%l,%v][%p%%]\ %{strftime(\"%d/%m/%y\ -\ %H:%M\")}

"set statusline=[%F]%y%r%m%*%=[Line:%l/%L,Column:%c][%p%%]

"        

set laststatus=2

"    (     )   ,   1,   2

set cmdheight=2

"       

filetype on

"         

filetype plugin on

"                

filetype indent on

"       

set viminfo+=!

"                 

set iskeyword+=_,$,@,%,#,-

"            

set linespace=0

"                

set wildmenu

"     (backspace)    indent, eol, start 

set backspace=2

"   backspace         

set whichwrap+=<,>,h,l

"    buffer         (  office           )

set mouse=a

set selection=exclusive

set selectmode=mouse,key

"     : commands  ,              

set report=0

"

set fillchars=vert:\ ,stl:\ ,stlnc:\

"          

set showmatch

"          (        )

set matchtime=1

"      buffer         3   

set scrolloff=3

"  C        

set smartindent

"       txt  (  txt.vim  )

au BufRead,BufNewFile *  setfiletype txt

"    

:inoremap ( ()<ESC>i

:inoremap ) <c-r>=ClosePair(')')<CR>

:inoremap { {<CR>}<ESC>O

:inoremap } <c-r>=ClosePair('}')<CR>

:inoremap [ []<ESC>i

:inoremap ] <c-r>=ClosePair(']')<CR>

:inoremap " ""<ESC>i

:inoremap ' ''<ESC>i

function! ClosePair(char)

    if getline('.')[col('.') - 1] == a:char

        return "\<Right>"

    else

        return a:char

    endif

endfunction

filetype plugin indent on 

"        ,             

set completeopt=longest,menu

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

" CTags     

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

let Tlist_Sort_Type = "name"    "         

let Tlist_Use_Right_Window = 1  "          

let Tlist_Compart_Format = 1    "       

let Tlist_Exist_OnlyWindow = 1  "       buffer,kill   kill buffer  

let Tlist_File_Fold_Auto_Close = 0  "          tags  

let Tlist_Enable_Fold_Column = 0    "          

autocmd FileType java set tags+=D:\tools\java\tags  

"autocmd FileType h,cpp,cc,c set tags+=D:\tools\cpp\tags  

"let Tlist_Show_One_File=1            "          tag,        

"  tags  

set tags=tags  

"set autochdir 



""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

"    

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

"    Taglist 

let Tlist_Auto_Open=1 

"""""""""""""""""""""""""""""" 

" Tag list (ctags) 

"""""""""""""""""""""""""""""""" 

let Tlist_Ctags_Cmd = '/usr/bin/ctags' 

let Tlist_Show_One_File = 1 "          tag,         

let Tlist_Exit_OnlyWindow = 1 "  taglist         ,   vim 

let Tlist_Use_Right_Window = 1 "        taglist  

" minibufexpl       

let g:miniBufExplMapWindowNavVim = 1

let g:miniBufExplMapWindowNavArrows = 1

let g:miniBufExplMapCTabSwitchBufs = 1
let g:miniBufExplModSelTarget = 1