今天重新配置了一下vim舍扰,將其配置成為了一個完整的IDE。包括自動補全陵且,文件列表,函數(shù)列表等
先來一張圖
下面是其配置文件:
set shortmess=atI " 啟動的時候不顯示那個援助烏干達兒童的提示
set nu " 顯示行號
syntax on " 語法高亮
set ruler " 顯示標尺
set showmode
set showcmd
set hlsearch
set nocompatible "去掉討厭的有關(guān)vi一致性模式聊疲,避免以前版本的一些bug和局限
set cursorcolumn "豎行高亮
set cursorline "當(dāng)前橫行高亮
set foldmethod=syntax "設(shè)置折疊
set foldlevelstart=99
set autoindent "自動縮進
set tabstop=2
set softtabstop=2
set shiftwidth=2
"配色方案
set t_Co=256
syntax enable
set background=dark
colorscheme molokai
let mapleader=";"
nmap <Leader>q :q<CR>
nmap <Leader>w :w<CR>
nmap <Leader>qa :qa<CR>
nmap <Leader>wq :wq<CR>
nmap <Leader>a za
nmap <CR> G
nmap <backspace> gg
inoremap jk <Esc>
inoremap ( ()<LEFT>
inoremap [ []<LEFT>
inoremap { {<CR>}<ESC>O
function HeaderPython()
call setline(1, "#coding: utf-8")
call append(1, "\#Created Time: ".strftime('%Y-%m-%d %T', localtime()))
call append(2,"")
normal G
endf
function Headersh()
call setline(1,"\#########################################################################")
call append(1,"\#File Name:".expand("%"))
call append(2,"\#Created Time:".strftime('%Y-%m-%d %T'))
call append(3, "\#########################################################################")
call append(4, "\#!/bin/bash")
call append(5,"")
normal G
endf
function Headercpp()
call setline(1,"/*******************************************************")
call append(1,"File Name:".expand("%"))
call append(2,"Created Time:".strftime('%Y-%m-%d %T'))
call append(3,"********************************************************/")
call append(4,"\#include<iostream>")
call append(5,"using namespace std;")
call append(6,"")
normal G
endf
autocmd bufnewfile *.py call HeaderPython()
autocmd bufnewfile *.sh call Headersh()
autocmd bufnewfile *.cpp call Headercpp()
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 == 'sh'
:!./%
elseif &filetype == 'python'
exec "!python %"
endif
endfunc
"Plugin
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required
Plugin 'gmarik/Vundle.vim'
Plugin 'scrooloose/nerdtree'
Plugin 'Valloric/YouCompleteMe'
Plugin 'vim-scripts/a.vim'
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
" To ignore plugin indent changes, instead use:
"filetype plugin on
let g:ycm_global_ycm_extra_conf = '~/.vim/bundle/YouCompleteMe/cpp/ycm/.ycm_extra_conf.py'
"NERDTree
map <C-N> :NERDTreeToggle<CR>
let NERDTreeShowBookmarks=1 "顯示書簽
let NERDTreeDirArrows=0 "目錄箭頭 1 顯示箭頭 0傳統(tǒng)+-|號
"autocmd VimEnter * NERDTree
"autocmd VimEnter * wincmd p
"autocmd VimEnter * if !argc() | NERDTree | endif
"Taglist
map <C-L> :Tlist<CR>
let Tlist_Show_One_File=0
let Tlist_Ctags_Cmd="/usr/bin/ctags" "將taglist與ctags關(guān)聯(lián)
let Tlist_Exit_OnlyWindow=1 "最后一個窗口時退出
let Tlist_Use_Right_Window=1
let Tlist_File_Fold_Auto_Close=1
"let Tlist_Auto_Open=1
"ctags
map <F9> :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .<CR>