爲了可以複製粘貼到外面,須要下載gvim,能夠自行下載。java
個人插件管理是用vim-plug來管理的python
下載命令ios
curl -fLo ~/.vim/autoload/plug.vim --create-dirs \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
而後在vimrc中添加以下代碼段c++
call plug#begin() """""中間放插件"""" call plug#end()
在中間放置須要的插件就能夠了.git
vim-plug管理插件時,只須要加入上面在代碼段中加入須要的插件命(以下),而後打開終端輸入vim,在按:輸入,PlugInstall,就能夠完成插件安裝。github
我本身在使用的一些插件。vim
neadtree 管理目錄用,我把快捷鍵設置成F3,可讓它開啓或關閉bash
Plug 'scrooloose/nerdtree'
nerdcommenter 代碼多行註釋用的,仍是挺不錯的,按住 \+c+space 就能夠註釋與反註釋了curl
Plug 'ddollar/nerdcommenter'
airline以及主題ide
Plug 'vim-airline/vim-airline' Plug 'vim-airline/vim-airline-themes'
airline使用前須要安裝powerline字體
安裝方法以下
# clone git clone https://github.com/powerline/fonts.git --depth=1 # install cd fonts ./install.sh # clean-up a bit cd .. rm -rf fonts
airline的主題目錄以下,能夠選擇本身想要的主題
~/.vim/plugged/vim-airline-themes/autoload/airline/themes
如下是個人以爲比較好看的主題。
aurora.vim base16_eighties.vim dracula.vim onedark.vim silver.vim
badcat.vim base16_isotope.vim hybridline.vim papercolor.vim term.vim
badwolf.vim base16_pop.vim minimalist.vim peaksea.vim understated.vim
base16_colors.vim bubblegum.vim molokai.vim ravenpower.vim vice.vim
base16color.vim deus.vim night_owl.vim raven.vim wombat.vim
其餘的主題就被我刪了。
如今我再用的vice和tomorrow主題,我認爲仍是蠻好看的。
只要在.vimrc中添加
let g:airline_theme="vice"
就能夠了。
最後是完整的.vimrc
" === " 設置快捷鍵 " === " inoremap ' ''<ESC>i " inoremap " ""<ESC>i " inoremap ( ()<ESC>i " inoremap [ []<ESC>i " inoremap { {<CR>}<ESC>O map Z ZZ map - $ map 0 ^ map S :w<CR> map tt :tabnew map tj :tabNext<CR> map tk :tabnext<CR> map gt <nop> map gT <nop> function! HideNumber() " <F2>開啓/關閉行號顯示 if(&relativenumber == &number) set relativenumber! number! elseif(&number) set number! else set relativenumber! endif set number? endfunc nnoremap <F2> :call HideNumber()<CR> let g:syntastic_cpp_compiler_options = ' -std=c++11 -stdlib=libc++' "F9編譯 map <F9> :call CR()<CR> func! CR() exec "w" if &filetype == 'cpp' exec "!g++ % -o %<" exec "!time ./%<" elseif &filetype == 'python' exec "!python %" endif endfunc " === " 設置編碼 " === 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 " === " === 基本設置 " === hi Normal cterm=NONE ctermfg=White gui=bold guifg=#ffffff hi Constant cterm=NONE ctermfg=LightCyan gui=NONE guifg=#00ffff set nocompatible " 不要使用vi的鍵盤模式,而是vim本身的 set clipboard =unnamed,unnamedplus " 共享剪貼板 syntax on " 語法高亮 set cursorline set whichwrap=<,>,[,],h,l " 容許backspace和光標鍵跨越行邊界 set nu " 顯示行號 set selection=exclusive set selectmode=mouse,key set listchars=tab:>-,trail:- set magic " 設置魔術 set guioptions-=T " 隱藏工具欄 set guioptions-=m " 隱藏菜單欄 set laststatus=2 " 老是顯示狀態欄 set showmatch " 高亮顯示匹配的括號 "匹配括號高亮的時間(單位是十分之一秒) hi MatchParen ctermbg=blue guibg=lightblue set matchtime=5 set ruler " 顯示光標當前位置 "個人狀態行顯示的內容(包括文件類型和解碼) set statusline=[%F]%y%r%m%*%=[Line:%l/%L,Column:%c][%p%%] set cmdheight=2 set autoindent " 自動縮進 set cindent " 以C語言的方式縮進 set shiftwidth=4 " 設置自動縮進的空格數量 set softtabstop=4 " tab鍵的實際佔有空格數,統一縮進 set tabstop=4 " 設置tab鍵的空格數 set smarttab " 在行和段開始處使用製表符 set mouse=a " 使用鼠標 set completeopt=preview,menu " 代碼補全 set nobackup " 從不備份 filetype plugin indent on " 容許插件 filetype on " 偵測文件類型 filetype plugin on " 載入文件類型插件 set viminfo+=! " 保存全局變量 set iskeyword+=_,$,@,%,#,- " 帶有以下符號的單詞不要被換行分割 set linespace=0 " 字符間插入的像素行數目 set wildmenu " 加強模式中的命令行自動完成操做 set backspace=2 " 使回格鍵(backspace)正常處理indent, eol, start等 set report=0 " 經過使用: commands命令,告訴咱們文件的哪一行被改變過 set fillchars=vert:\ ,stl:\ ,stlnc:\ " 在被分割的窗口間顯示空白,便於閱讀 set scrolloff=5 " 光標移動到buffer的頂部和底部時保持3行距離 set nobackup " 禁止生成臨時文件 set noswapfile " 禁止生成交換文件 set autoread " 設置當文件被改動時自動載入 set autowrite " 自動保存 set history=1000 " 歷史記錄數 set confirm " 在處理未保存或只讀文件的時候,彈出確認 set ignorecase " 搜索忽略大小寫 set hlsearch " 搜索逐字符高亮 set incsearch set gdefault " 行內替換 set relativenumber number " 相對行號: 行號變成相對 " === " === 插入模式下用絕對行號, 普通模式下用相對 " === au FocusLost * :set norelativenumber number au FocusGained * :set relativenumber autocmd InsertEnter * :set norelativenumber number autocmd InsertLeave * :set relativenumber "複製選中區到系統剪切板中 vnoremap <leader>y "+y if has("autocmd") " 打開自動定位到最後編輯的位置, 須要確認 .viminfo 當前用戶可寫 au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif endif " === " === vimplug " === call plug#begin() " 中間放插件 Plug 'scrooloose/nerdtree' Plug 'ddollar/nerdcommenter' Plug 'vim-airline/vim-airline' Plug 'vim-airline/vim-airline-themes' Plug 'jiangmiao/auto-pairs' call plug#end() " === " === NERDTree " === let NERDChristmasTree=1 " 顯示加強 let NERDTreeAutoCenter=1 " 自動調整焦點 let NERDTreeMouseMode=2 " 鼠標模式:目錄單擊,文件雙擊 let NERDTreeShowFiles=1 " 顯示文件 " let NERDTreeShowHidden=1 " 顯示隱藏文件 let NERDTreeHightCursorline=1 " 高亮顯示當前文件或目錄 let NERDTreeShowLineNumbers=1 " 顯示行號 let NERDTreeWinPos='left' " 窗口位置 let NERDTreeWinSize=31 " 窗口寬度 let g:NERDTreeCaseSensitiveSort = 1 let g:nerdtree_tabs_open_on_console_startup=1 let NERDTreeIgnore=['\.pyc','\~$','\.swp'] let g:NERDTreeIndicatorMapCustom = { \ "Modified" : "✹", \ "Staged" : "✚", \ "Untracked" : "✭", \ "Renamed" : "➜", \ "Unmerged" : "═", \ "Deleted" : "✖", \ "Dirty" : "✗", \ "Clean" : "✔︎", \ 'Ignored' : '☒', \ "Unknown" : "?" \ } " 快捷鍵 nnoremap <silent> <F3> :NERDTreeToggle<CR> set t_Co=256 set laststatus=2 set lazyredraw " === " === airline " === " let g:airline#extensions#tabline#enabled = 1 " let g:airline#extensions#tabline#buffer_nr_show = 1 let g:airline_theme="vice" let g:airline_powerline_fonts = 1 " === " === 新文件標題 " === " 新建.c,.h,.sh,.java文件,自動插入文件頭 autocmd BufNewFile *.cpp,*.[ch],*.sh,*.java exec ":call SetTitle()" " 定義函數SetTitle,自動插入文件頭 func SetTitle() let l = 0 if &filetype == 'sh' let l = l+1 | call setline(l,"\###############################################################") let l = l+1 | call setline(l, "\# File Name : ".expand("%")) let l = l+1 | call setline(l, "\# Author : Jiaaaaaaaqi") let l = l+1 | call setline(l, "\# Created Time : ".strftime("%c")) let l = l+1 | call setline(l, "\###############################################################") let l = l+1 | call setline(l, "\#!/bin/bash") else let l = l+1 | call setline(l, "/*************************************************************** ") let l = l+1 | call setline(l, " > File Name : ".expand("%")) let l = l+1 | call setline(l, " > Author : Jiaaaaaaaqi") let l = l+1 | call setline(l, " > Created Time : ".strftime("%c")) let l = l+1 | call setline(l, " ***************************************************************/") let l = l+1 | call setline(l, "") endif if &filetype == 'cpp' let l = l+1 | call setline(l, "#include <map>") let l = l+1 | call setline(l, "#include <set>") let l = l+1 | call setline(l, "#include <list>") let l = l+1 | call setline(l, "#include <ctime>") let l = l+1 | call setline(l, "#include <cmath>") let l = l+1 | call setline(l, "#include <stack>") let l = l+1 | call setline(l, "#include <queue>") let l = l+1 | call setline(l, "#include <cfloat>") let l = l+1 | call setline(l, "#include <string>") let l = l+1 | call setline(l, "#include <vector>") let l = l+1 | call setline(l, "#include <cstdio>") let l = l+1 | call setline(l, "#include <bitset>") let l = l+1 | call setline(l, "#include <cstdlib>") let l = l+1 | call setline(l, "#include <cstring>") let l = l+1 | call setline(l, "#include <iostream>") let l = l+1 | call setline(l, "#include <algorithm>") let l = l+1 | call setline(l, "#include <unordered_map>") let l = l+1 | call setline(l, "#define lowbit(x) x & (-x)") let l = l+1 | call setline(l, "#define mes(a, b) memset(a, b, sizeof a)") let l = l+1 | call setline(l, "#define fi first") let l = l+1 | call setline(l, "#define se second") let l = l+1 | call setline(l, "#define pb push_back") let l = l+1 | call setline(l, "#define pii pair<int, int>") let l = l+1 | call setline(l, "") let l = l+1 | call setline(l, "typedef unsigned long long int ull;") let l = l+1 | call setline(l, "typedef long long int ll;") let l = l+1 | call setline(l, "const int maxn = 1e5 + 10;") let l = l+1 | call setline(l, "const int maxm = 1e5 + 10;") let l = l+1 | call setline(l, "const ll mod = 1e9 + 7;") let l = l+1 | call setline(l, "const ll INF = 1e18 + 100;") let l = l+1 | call setline(l, "const int inf = 0x3f3f3f3f;") let l = l+1 | call setline(l, "const double pi = acos(-1.0);") let l = l+1 | call setline(l, "const double eps = 1e-8;") let l = l+1 | call setline(l, "using namespace std;") let l = l+1 | call setline(l, "") let l = l+1 | call setline(l, "int n, m;") let l = l+1 | call setline(l, "int cas, tol, T;") let l = l+1 | call setline(l, "") let l = l+1 | call setline(l, "int main() {") let l = l+1 | call setline(l, ' // freopen("in", "r", stdin);') let l = l+1 | call setline(l, "") let l = l+1 | call setline(l, " return 0;") let l = l+1 | call setline(l, "}") let l = l+1 | call setline(l, "") endif endfunc " 新建文件後,自動定位到文件末尾 autocmd BufNewFile * normal G