1. 程式人生 > >vim用戶設置

vim用戶設置

%d powerline rtc rem 不顯示 scroll cursor normal g++

此配置目前使用戶mac,linux,win,但是win系統需要提前配置mingw32相關的gcc系統路徑等信息。

" Setting some decent VIM settings for programming" This source file comes from git-for-windows build-extra repository (git-extra/vimrc)
ru! defaults.vim " Use Enhanced Vim defaultsset mouse= " Reset the mouse setting from defaultsaug vimStartup | au! | aug END " Revert last positioned jump, as it is defined below
let g:skip_defaults_vim = 1 " Do not source defaults.vim again (after loading this system vimrc)
set ai " set auto-indenting on for programmingset showmatch " automatically show matching brackets. works like it does in bbedit.set vb " turn on the "
visual bell" - which is much quieter than the "audio blink"set laststatus=2 " make the last line where the status is two lines deep so you can see status alwaysset showmode " show the current modeset clipboard=unnamed " set clipboard to unnamed to access the system clipboard under windowsset wildmode
=list:longest,longest:full " Better command line completion
" Show EOL type and last modified timestamp, right after the filename" Set the statuslineset statusline=%f " filename relative to current $PWDset statusline+=%h " help file flagset statusline+=%m " modified flagset statusline+=%r " readonly flagset statusline+=\ [%{&ff}] " Fileformat [unix]/[dos] etc...set statusline+=\ (%{strftime(\"%H:%M\ %d/%m/%Y\",getftime(expand(\"%:p\")))}) " last modified timestampset statusline+=%= " Rest: right alignset statusline+=%l,%c%V " Position in buffer: linenumber, column, virtual columnset statusline+=\ %P " Position in buffer: Percentage
if &term =~ ‘xterm-256color‘ " mintty identifies itself as xterm-compatible if &t_Co == 8 set t_Co = 256 " Use at least 256 colors endif " set termguicolors " Uncomment to allow truecolors on minttyendif"------------------------------------------------------------------------------" Only do this part when compiled with support for autocommands.if has("autocmd") " Set UTF-8 as the default encoding for commit messages autocmd BufReadPre COMMIT_EDITMSG,MERGE_MSG,git-rebase-todo setlocal fileencodings=utf-8
" Remember the positions in files with some git-specific exceptions" autocmd BufReadPost * \ if line("‘\"") > 0 && line("‘\"") <= line("$") \ && &filetype !~# ‘commit\|gitrebase‘ \ && expand("%") !~ "ADD_EDIT.patch" \ && expand("%") !~ "addp-hunk-edit.diff" | \ exe "normal g`\"" | \ endif
autocmd BufNewFile,BufRead *.patch set filetype=diff
autocmd Filetype diff \ highlight WhiteSpaceEOL ctermbg=red | \ match WhiteSpaceEOL /\(^+.*\)\@<=\s\+$/endif " has("autocmd")



syntax enableset numberset cursorlineset ruler"set shiftwidth=4
"==========================================" Common Settings"==========================================" 開啟語法高亮syntax enable" 開啟語法高亮syntax on" 設置字體set guifont=Monaco" 設置歷史記錄條數set history=999" 檢測文件類型filetype on" 針對不同的文件,采用不同的縮進方式filetype indent on" 允許插件filetype plugin on" 啟動自動補全filetype plugin indent on" 文件修改之後自動讀入set autoread" 啟動後不顯示提示"set shortmess=atI" 設置取消備份,禁止臨時文件生成set nobackupset noswapfile" create undo fileset undolevels=1000 " how many undosset undoreload=10000 " number of lines to save for undoif v:version >= 730set undofile " keep a persistent backup fileset undodir=/tmp/vimundo/endif"set wildignore=*.swp,*.bak,*.pyc,*.class,.svn" 顯示當前橫豎線"set cursorline"set cursorcolumn" 設置退出Vim之後內容顯示在終端屏幕,可以用於查看和復制" 好處:誤刪什麽,如果以前屏幕打開可以用來找回"set t_ti= t_te=" 設置在Vim中可以使用鼠標,防止終端無法拷貝"set mouse=a
"==========================================" Display Settings"==========================================" 顯示當前行號和列號set ruler" 在狀態欄顯示正在輸入的命令set showcmd" 左下角顯示當前Vim模式set showmode" 光標移動至少保留的行數"set scrolloff=7" 命令行(在狀態行下)的高度,默認為1,這裏是2set statusline=%<%f\ %h%m%r%=%k[%{(&fenc==\"\")?&enc:&fenc}%{(&bomb?\",BOM\":\"\")}]\ %-14.(%l,%c%V%)\ %P" 總是顯示狀態欄(Powerline需要2行)set laststatus=2" 顯示行號set number" 指定不折行set nowrap" 設置代碼匹配,包括括號匹配情況set showmatch" how many tenths of a second to blink when matching brackets" setmatchtime=2" 開啟及時搜索(is)set incsearch" 設置搜索高亮(hlsearch)set hls" 設置搜索時忽略大小寫set ignorecase" 當搜索的時候嘗試smarset smartcase" 設置代碼折疊"set foldenable" 折疊方法" manual 手工折疊" indent 縮進折疊" expr 表達式折疊" syntax 語法折疊" diff 對沒有更改的文件折疊" marker 標記折疊"set foldmethod=inden"set foldlevel=99" 設置C/C++方式自動對齊set autoindentset cindentset smartindent" 設置tab寬度set tabstop=4" 設置自動對齊空格數set shiftwidth=4" 按退格鍵時可以一次刪除4個空格"set softtabstop=4" 編輯的時候將所有的tab設置為空格(expandtab)set et" 使用Backspace直接刪除tabset smarttab" 不在單詞中間折行set lbr
"==========================================" FileEncode Settings"==========================================" 設置編碼方式set encoding=utf-8" 設置打開文件的編碼格式set fileencodings=ucs-bom,utf-8,cp936,gb18030,big5,euc-jp,euc-kr,latin1set helplang=cn" 只對終端影響(默認)set termencoding=utf-8" use UNIX as the standard file typeset ffs=unix,dos,mac" 如遇Unicode值大於255的文本,不必等到空格再折行。set formatoptions+=m" 合並兩行中文時,不在中間加空格:set formatoptions+=B
"==========================================" HotKey Settings"==========================================:set pastetoggle=<F12>
"==========================================" Theme Settings"==========================================" 設置主題" set background=dark" colorscheme evening" set t_Co=256
"==========================================" Other Settings"==========================================" Uncomment the following to have Vim jump to the last position when reopening a fileif has("autocmd") au BufReadPost * if line("‘\"") > 1 && line("‘\"") <= line("$") | exe "normal! g‘\"" | endifendif
func! CompileGcc() exec "w" let compilecmd="!gcc " let compileflag="-o %< " if search("glut\.h") != 0 let compileflag .= " -lglut -lGLU -lGL " endif exec compilecmd." % ".compileflagendfunc
func! CompileGpp() exec "w" let compilecmd="!g++ -std=c++11 " let compileflag="-o %< " if search("glut\.h") != 0 let compileflag .= " -lglut -lGLU -lGL " endif exec compilecmd." % ".compileflagendfunc
func! RunPython() exec "!python %"endfunc
func! CompileJava() exec "!javac %"endfunc
func! CompileCode() exec "w" if &filetype == "cpp" exec "call CompileGpp()" elseif &filetype == "c" exec "call CompileGcc()" elseif &filetype == "python" exec "call RunPython()" elseif &filetype == "java" exec "call CompileJava()" endifendfunc
func! RunResult() exec "w" if &filetype == "c" exec "! ./%<" elseif &filetype == "cpp" exec "! ./%<" elseif &filetype == "python" exec "call RunPython" elseif &filetype == "java" exec "!java %<" endifendfunc
map <F5> :call RunResult()<CR>map <F9> :call CompileCode()<CR>imap <F9> <ESC>:call CompileCode()<CR>vmap <F9> <ESC>:call CompileCode()<CR>
pasting

vim用戶設置