From adfb07ca02cbb4079c8df537042aaa1573770d52 Mon Sep 17 00:00:00 2001 From: Ein Verne Date: Wed, 10 Jun 2015 21:36:06 +0800 Subject: [PATCH] update vimrc: maxium gvim when start --- _vimrc | 50 +++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 45 insertions(+), 5 deletions(-) diff --git a/_vimrc b/_vimrc index 18d1f86..9cc9e92 100644 --- a/_vimrc +++ b/_vimrc @@ -1,3 +1,21 @@ +"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" => Judge current OS is Windows or Linux +"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +if(has("win32") || has("win64") || has("win95") || has("win16")) + let g:iswindows = 1 +else + let g:iswindows = 0 +endif + +"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" => Judge current process is vim or gvim +"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +if has("gui_running") + let g:isGUI = 1 +else + let g:isGUI = 0 +endif + " 引用vundle_vimrc source $VIM/vundle_vimrc @@ -26,14 +44,24 @@ let g:mapleader = "," nmap w :w! "编辑vimrc之后,重新加载 -autocmd! bufwritepost _vimrc source $VIM/_vimrc +if g:iswindows + autocmd! bufwritepost _vimrc source $VIM/_vimrc +else + autocmd! bufwritepost *.vimrc source $HOME/.vimrc +endif """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " => VIM user interface """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" set 7 lines to the cursor - when moving vertically using j/k +" set 8 lines to the cursor - when moving vertically using j/k +" j/k移动时光标距离文件上下n行 缩写 set so = 8 set scrolloff=8 +" gVim automatically maximize when it open +" 启动时最大化gVim +" http://superuser.com/questions/140419/how-to-start-gvim-maximized +au GUIEnter * simalt ~x + " 如下命令使鼠标用起来象微软 Windows behave mswin @@ -42,8 +70,10 @@ set cursorline " always show current position set ruler + " height of the command bar set cmdheight=2 + " in many terminal emulators the mouse works just fine, thus enable it if has('mouse') set mouse=a @@ -90,13 +120,13 @@ colorscheme molokai "vim内部编码 set encoding=utf-8 +" set current file encoding +set fileencoding=utf-8 "按照utf-8 without bom,utf-8,顺序识别打开文件 set fileencodings=ucs-bom,utf-8,gbk,gb2312,cp936,big5,gb18030,shift-jis,latin1 -set fileencoding=utf-8 - "防止菜单乱码 -if(has("win32") || has("win64") || has("win95") || has("win16")) +if(g:iswindows && g:isGUI) source $VIMRUNTIME/delmenu.vim source $VIMRUNTIME/menu.vim language messages zh_CN.utf-8 @@ -117,6 +147,7 @@ set guifontwide=NSimsun\:h12 " => Files, backups and undo """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Turn backup off, since most stuff is in SVN, git et.c anyway... +" no backup file, no write backup file, no swap file set nobackup set nowb set noswapfile @@ -206,6 +237,9 @@ let g:jedi#popup_on_dot = 0 " no ddkP " no ddp +"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" =>Others +"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Delete trailing white space on save, useful for Python and CoffeeScript ;) func! DeleteTrailingWS() exe "normal mz" @@ -215,6 +249,12 @@ endfunc autocmd BufWrite *.py :call DeleteTrailingWS() autocmd BufWrite *.coffee :call DeleteTrailingWS() +" smart way to move between windows +map j +map k +map h +map l + set diffexpr=MyDiff() function! MyDiff() let opt = '-a --binary '