map <F9> :call SaveInputData()<CR>func! SaveInputData() exec "tabnew" exec 'normal "+gP' exec "w! /tmp/input_data"endfunc" YouCompleteMeset runtimepath+=~/.vim/bundle/YouCompleteMelet g:ycm_collect_identifiers_from_tags_files = 1 " 開啟 YCM基於標籤引擎let g:ycm_collect_identifiers_from_comments_and_strings = 1 "" 注釋與字串中的內容也用於補全let g:syntastic_ignore_files=[".*\.py$"]let g:ycm_seed_identifiers_with_syntax = 1 " 文法關鍵字補全let g:ycm_complete_in_comments = 1let g:ycm_confirm_extra_conf = 0let g:ycm_key_list_select_completion = ['<c-n>', '<Down>'] " 映射按鍵," 沒有這個會攔截掉tab, 導致其他外掛程式的tab不能用.let g:ycm_key_list_previous_completion = ['<c-p>', '<Up>']let g:ycm_complete_in_comments = 1 " 在注釋輸入中也能補全let g:ycm_complete_in_strings = 1 " 在字串輸入中也能補全let g:ycm_collect_identifiers_from_comments_and_strings = 1 " 注釋和字串中的文字也會被收入補全let g:ycm_global_ycm_extra_conf='~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py'let g:ycm_show_diagnostics_ui = 0 " 禁用語法檢查inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<CR>" | " 斷行符號即選中當前項nnoremap <c-j> :YcmCompleter GoToDefinitionElseDeclaration<CR>| " 跳轉到定義處let g:ycm_min_num_of_chars_for_completion=2 " 從第2個鍵入字元就開始羅列匹配項"""""""""''"""'''']"'''']"""]"""let g:ycm_global_ycm_extra_conf='~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py'"let g:ycm_global_ycm_extra_conf=0 "colorscheme torte"colorscheme murphy"colorscheme desert "colorscheme desert "colorscheme elflordcolorscheme ronset completeopt=longest,menu "讓Vim的補全菜單行為與一般IDE一致(參考VimTip1228)autocmd InsertLeave * if pumvisible() == 0|pclose|endif "離開插入模式後自動關閉預覽視窗inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<CR>" "斷行符號即選中當前項"上下左右鍵的行為 會顯示其他資訊"inoremap <expr> <Down> pumvisible() ? "\<C-n>" : "\<Down>""inoremap <expr> <Up> pumvisible() ? "\<C-p>" : "\<Up>""inoremap <expr> <PageDown> pumvisible() ? "\<PageDown>\<C-p>\<C-n>" : "\<PageDown>""inoremap <expr> <PageUp> pumvisible() ? "\<PageUp>\<C-p>\<C-n>" : "\<PageUp>""""youcompleteme 預設tab s-tab 和自動補全衝突"let g:ycm_key_list_select_completion=['<c-n>']"let g:ycm_key_list_select_completion = ['<Down>']""let g:ycm_key_list_previous_completion=['<c-p>']let g:ycm_key_list_previous_completion = ['<Up>']let g:ycm_confirm_extra_conf=0 "關閉載入.ycm_extra_conf.py提示let g:ycm_collect_identifiers_from_tags_files=1 " 開啟 YCM 基於標籤引擎let g:ycm_min_num_of_chars_for_completion=2 " 從第2個鍵入字元就開始羅列匹配項let g:ycm_cache_omnifunc=0 " 禁止緩衝匹配項,每次都重建匹配項let g:ycm_seed_identifiers_with_syntax=1 " 文法關鍵字補全nnoremap <F5> :YcmForceCompileAndDiagnostics<CR> "force recomile with syntastic"nnoremap <leader>lo :lopen<CR> "open locationlist""nnoremap <leader>lc :lclose<CR> "close locationlistinoremap <leader><leader> <C-x><C-o>"在注釋輸入中也能補全"let g:ycm_complete_in_comments = 1""在字串輸入中也能補全let g:ycm_complete_in_strings = 1"注釋和字串中的文字也會被收入補全"let g:ycm_collect_identifiers_from_comments_and_strings = 0""nnoremap <leader>jd :YcmCompleter GoToDefinitionElseDeclaration<CR> " 跳轉到定義處"""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"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 顯示相關 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""set shortmess=atI " 啟動的時候不顯示那個援助烏幹達兒童的提示 "winpos 5 5 " 設定視窗位置 "set lines=40 columns=155 " 設定視窗大小 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-8endif" 設定色彩配置"colorscheme murphy"字型 "if (has("gui_running")) " set guifont=Bitstream\ Vera\ Sans\ Mono\ 10 "endif """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""新檔案標題"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""建立.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: ma6174@163.com") 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: lgj") call append(line(".")+2, " > Mail: liang_gj18@163.com ") 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, "") call append(line(".")+9, "int main(void)") call append(line(".")+10, "{") call append(line(".")+11, "") call append(line(".")+12, " cout <<\"********system start***********\" << endl ;") call append(line(".")+13, " return 0;") call append(line(".")+14,"}") endif if &filetype == 'c' call append(line(".")+6, "#include<stdio.h>") call append(line(".")+7, "") call append(line(".")+8, "int main(int argc ,char *argv[])") call append(line(".")+9, "{") call append(line(".")+10, "") call append(line(".")+11, " printf(\"\\r\\n********systerm start **************\\r\\n\");") call append(line(".")+12, "") call append(line(".")+13, " printf(\"\\r\\n********systerm finish **************\\r\\n\");") call append(line(".")+14, " return 1;") call append(line(".")+15, "}") endif " if &filetype == 'java' " call append(line(".")+6,"public class ".expand("%")) " call append(line(".")+7,"") " endif "建立檔案後,自動定位到檔案末尾 autocmd BufNewFile * normal Gendfunc """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""鍵盤命令""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""nmap <leader>w :w!<cr>nmap <leader>f :find<cr>" 映射全選+複製 ctrl+amap <C-A> ggVGYmap! <C-A> <Esc>ggVGYmap <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' :!./% elseif &filetype == 'py' exec "!python %" exec "!python %<" endifendfunc"C,C++的調試map <F8> :call Rungdb()<CR>func! Rungdb() exec "w" exec "!g++ % -g -o %<" exec "!gdb ./%<"endfunc""""""