很奇怪的事...不會解釋java
建議編譯位置第一次設置爲ios
map <F9> :call CR()<CR>
func! CR()
exec "w"
exec "!g++ -std=c++11 % -o %<"
exec "!gdb %<.exe"
endfuncc++
而後運行一次事後在設置爲以下代碼shell
source $VIMRUNTIME/vimrc_example.vim behave xterm set diffexpr=MyDiff() function MyDiff() let opt = '-a --binary ' if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif let arg1 = v:fname_in if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif let arg1 = substitute(arg1, '!', '\!', 'g') let arg2 = v:fname_new if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif let arg2 = substitute(arg2, '!', '\!', 'g') let arg3 = v:fname_out if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif let arg3 = substitute(arg3, '!', '\!', 'g') if $VIMRUNTIME =~ ' ' if &sh =~ '\<cmd' if empty(&shellxquote) let l:shxq_sav = '' set shellxquote& endif let cmd = '"' . $VIMRUNTIME . '\diff"' else let cmd = substitute($VIMRUNTIME, ' ', '" ', '') . '\diff"' endif else let cmd = $VIMRUNTIME . '\diff' endif let cmd = substitute(cmd, '!', '\!', 'g') silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3 if exists('l:shxq_sav') let &shellxquote=l:shxq_sav endif endfunction "共享剪貼板 set clipboard =unnamed,unnamedplus " 語法高亮 syntax on colorscheme industry inoremap ' ''<ESC>i inoremap " ""<ESC>i inoremap ( ()<ESC>i inoremap [ []<ESC>i inoremap { {<CR>}<ESC>O inoremap ) <c-r>=ClosePair(')')<CR> inoremap } <c-r>=ClosePair('}')<CR> inoremap ] <c-r>=ClosePair(']')<CR> function! ClosePair(char) if getline('.')[col('.') - 1] == a:char return "\<Right>" else return a:char endif endfunction filetype plugin indent on """"""""""""""""""""""""""""""""""鍵盤設置"""""""""""""""""""""""""""""""""""" " F2 行號開關,用於鼠標複製代碼用 " 爲方便複製,用<F2>開啓/關閉行號顯示: function! HideNumber() if(&relativenumber == &number) set relativenumber! number! elseif(&number) set number! else set relativenumber! endif set number? endfunc nnoremap <F2> :call HideNumber()<CR> "F9編譯" map <F9> :call CR()<CR> func! CR() exec "w" exec "!g++ -std=c++11 % -o %<" exec "!%<.exe" 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 " 容許backspace和光標鍵跨越行邊界 set whichwrap=<,>,[,],h,l "顯示行號" set nu "當前行" "set cursorline "使用鼠標" set mouse=a set selection=exclusive set selectmode=mouse,key set listchars=tab:>-,trail:- " 顯示中文幫助 if version >= 603 set helplang=cn set encoding=utf-8 endif 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 completeopt=preview,menu "從不備份 set nobackup "容許插件 " 偵測文件類型 filetype on " 載入文件類型插件 filetype plugin on " 保存全局變量 set viminfo+=! " 帶有以下符號的單詞不要被換行分割 set iskeyword+=_,$,@,%,#,- " 字符間插入的像素行數目 set linespace=0 " 加強模式中的命令行自動完成操做 set wildmenu " 使回格鍵(backspace)正常處理indent, eol, start等 set backspace=2 " 經過使用: commands命令,告訴咱們文件的哪一行被改變過 set report=0 " 在被分割的窗口間顯示空白,便於閱讀 set fillchars=vert:\ ,stl:\ ,stlnc:\ " 光標移動到buffer的頂部和底部時保持3行距離 set scrolloff=3 "禁止生成臨時文件 set nobackup set noswapfile " 設置當文件被改動時自動載入 set autoread "自動保存 set autowrite "容許插件 filetype plugin on " 歷史記錄數 set history=1000 " 在處理未保存或只讀文件的時候,彈出確認 set confirm "搜索忽略大小寫 set ignorecase "搜索逐字符高亮 set hlsearch set incsearch "行內替換 set gdefault " 相對行號: 行號變成相對,能夠用 nj/nk 進行跳轉 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 " 打開自動定位到最後編輯的位置, 須要確認 .viminfo 當前用戶可寫 if has("autocmd") au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif endif """""""""""""""""""""""""""""""""vim-plug"""""""""""""""""""""""""""""""""""" call plug#begin() """""中間放插件"""" Plug 'scrooloose/nerdtree' Plug 'ddollar/nerdcommenter' Plug 'vim-airline/vim-airline' Plug 'vim-airline/vim-airline-themes' call plug#end() """"""""""""""""""""""""""""""""""NERDTree"""""""""""""""""""""""""""""""""""" let NERDChristmasTree=1 "顯示加強 let NERDTreeAutoCenter=1 "自動調整焦點 let NERDTreeMouseMode=2 "鼠標模式:目錄單擊,文件雙擊 "let NERDTreeQuitOnOpen=1 "打開文件後自動關閉 let NERDTreeShowFiles=1 "顯示文件 let NERDTreeShowHidden=1 "顯示隱藏文件 let NERDTreeHightCursorline=1 "高亮顯示當前文件或目錄 let NERDTreeShowLineNumbers=1 "顯示行號 let NERDTreeWinPos='left' "窗口位置 let NERDTreeWinSize=25 "窗口寬度 let NERDTreeMinimalUI=1 "不顯示'Bookmarks' label 'Press ? for help' 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> "快捷鍵 let g:airline_theme="random" """""""""""""""""""""""""""""""""新文件標題"""""""""""""""""""""""""""""""""""" "新建.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 : Jiaaaaaaaqi") call append(line(".")+2, "\# Created Time : ".strftime("%c")) call append(line(".")+3, "\###############################################################") call append(line(".")+4, "\#!/bin/bash") else call setline(1, "/***************************************************************") call append(line("."), " > File Name : ".expand("%")) call append(line(".")+1, " > Author : Jiaaaaaaaqi") call append(line(".")+2, " > Created Time : ".strftime("%c")) call append(line(".")+3, " ***************************************************************/") call append(line(".")+4, "") endif if &filetype == 'cpp' call append(line(".")+5, "#include <map>") call append(line(".")+6, "#include <set>") call append(line(".")+7, "#include <list>") call append(line(".")+8, "#include <ctime>") call append(line(".")+9, "#include <cmath>") call append(line(".")+10, "#include <stack>") call append(line(".")+11, "#include <queue>") call append(line(".")+12, "#include <cfloat>") call append(line(".")+13, "#include <string>") call append(line(".")+14, "#include <vector>") call append(line(".")+15, "#include <cstdio>") call append(line(".")+16, "#include <bitset>") call append(line(".")+17, "#include <cstdlib>") call append(line(".")+18, "#include <cstring>") call append(line(".")+19, "#include <iostream>") call append(line(".")+20, "#include <algorithm>") call append(line(".")+21, "#define lowbit(x) x & (-x)") call append(line(".")+22, "#define mes(a, b) memset(a, b, sizeof a)") call append(line(".")+23, "#define fi first") call append(line(".")+24, "#define se second") call append(line(".")+25, "#define pii pair<int, int>") call append(line(".")+26, "") call append(line(".")+27, "typedef unsigned long long int ull;") call append(line(".")+28, "typedef long long int ll;") call append(line(".")+29, "const int maxn = 1e5 + 10;") call append(line(".")+30, "const int maxm = 1e5 + 10;") call append(line(".")+31, "const ll mod = 1e9 + 7;") call append(line(".")+32, "const ll INF = 1e18 + 100;") call append(line(".")+33, "const int inf = 0x3f3f3f3f;") call append(line(".")+34, "const double pi = acos(-1.0);") call append(line(".")+35, "const double eps = 1e-8;") call append(line(".")+36, "using namespace std;") call append(line(".")+37, "") call append(line(".")+38, "int n, m;") call append(line(".")+39, "int cas, tol, T;") call append(line(".")+40, "") call append(line(".")+41, "int main() {") call append(line(".")+42, "") call append(line(".")+43, "}") call append(line(".")+44, "") endif endfunc "新建文件後,自動定位到文件末尾 autocmd BufNewFile * normal G
配色方案選擇industryvim
windows下顏色太少了...難受啊windows
" Vim color file " Maintainer: Shian Lee " Last Change: 2014 Mar 6 (for vim 7.4) " Remark: "industry" stands for 'industrial' color scheme. In industrial " HMI (Human-Machine-Interface) programming, using a standard color " scheme is mandatory in many cases (in traffic-lights for example): " LIGHT_RED is 'Warning' " LIGHT_YELLOW is 'Attention' " LIGHT_GREEN is 'Normal' " LIGHT_MAGENTA is 'Warning-Attention' (light RED-YELLOW) " LIGHT_CYAN is 'Attention-Normal' (light YELLOW-GREEN). " BLACK is Dark-High-Contrast Background for maximum safety. " BLUE is Shade of BLACK (not supposed to get attention). " " Industrial color scheme is by nature clear, safe and productive. " Yet, depends on the file type's syntax, it might appear incorrect. " Reset to dark background, then reset everything to defaults: set background=dark highlight clear if exists("syntax_on") syntax reset endif let colors_name = "industry" " First set Normal to regular white on black text colors: hi Normal ctermfg=White ctermbg=Black guifg=#dddddd guibg=Black " Syntax highlighting (other color-groups using default, see :help group-name): hi comment guifg=green hi Constant cterm=NONE ctermfg=LightCyan gui=NONE guifg=#00ffff hi Identifier cterm=NONE ctermfg=LightMagenta gui=NONE guifg=#ff00ff hi Function cterm=NONE ctermfg=LightGreen gui=NONE guifg=#00ff00 hi Statement cterm=NONE ctermfg=7 gui=bold guifg=#ffffff hi PreProc cterm=NONE ctermfg=green gui=NONE guifg=#ffff00 hi Type cterm=NONE ctermfg=LightGreen gui=bold guifg=#00ff00 hi Special cterm=NONE ctermfg=LightMagenta gui=NONE guifg=#ff0000 hi Delimiter cterm=NONE ctermfg=blue gui=NONE guifg=#ffff00 "hi LineNr cterm=NONE ctermfg=3 guifg=Brown
airline我只保留了一些主題,而後random主題bash
atomic
base16_greenscreen
base16_monokai
base16_summerfruit
base16color
biogoo
cool
dark_minimal
hybrid
jellybeans
minimalist
molokai
onedark
papercolor
powerlineish
silver
sol
term
tomorrow
understated
violet
wombat
xtermlight
zenburn