Last active
December 30, 2015 16:19
-
-
Save 0xffan/7853637 to your computer and use it in GitHub Desktop.
My Vim config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"====================================== | |
" Author: WarrenFan | |
" Last Modified: 2013-12-08 | |
" Sections: | |
" > General | |
" > View | |
" > Utility | |
" > Plugins | |
"====================================== | |
"====================================== | |
" General | |
"====================================== | |
execute pathogen#infect() | |
set nocompatible | |
set autoread " autoload when file was modified | |
"set backup | |
"set backupext=.bak | |
"set backupdir=~/bakup/vim_bak/ | |
set nobackup | |
set noswapfile | |
filetype on | |
filetype indent on | |
filetype plugin on | |
filetype plugin indent on | |
set encoding=utf-8 | |
set fileencodings=utf-8,gbk,cp936 | |
set termencoding=utf-8 " only effective in non-GUI VIM | |
set ffs=unix,dos,mac " use Unix as the standard file type | |
set autochdir | |
set backspace=indent,eol,start | |
set formatoptions+=m | |
set formatoptions+=B | |
"====================================== | |
" View | |
"====================================== | |
syntax enable | |
syntax on | |
if has('gui_running') | |
set background=light | |
set lines=35 columns=117 | |
set cursorline " highlight current line | |
"hi cursorline guibg=#222222 | |
set guioptions-=T " hidden the toolbar | |
set guioptions-=L " hidden left scroll bar | |
set guioptions-=r " hidden right scroll bar | |
"set guifont=Monaco:h11 " Windows | |
set guifont=Monaco\ 11 " Linux | |
set mousehide " hide the mouse cursor when typing | |
else | |
set background=dark | |
set guifont=Monaco\ 11 " Linux | |
"set guifont=Monaco:h11 " Windows | |
endif | |
colorscheme solarized | |
set number " show line number | |
set numberwidth=4 | |
set nolinebreak | |
set nowrap " do not automatically warp | |
set showmatch | |
set mat=2 " How many tenths of a second to blink | |
" when matching brackets | |
set foldenable " enable code foldig | |
set foldmethod=indent " manual, indent, expr, syntx, diff, marker | |
set foldlevel=10 | |
function SimpleFoldText() | |
return getline(v:foldstart).' ' | |
endfunction | |
set foldtext=SimpleFoldText() " Custom fold text function | |
" (cleaner than default) | |
set smartindent | |
set autoindent | |
set tabstop=4 | |
set shiftwidth=4 " number of spaces to use for autoindenting | |
set softtabstop=4 " delete 4 spaces when type <Backspace> | |
set smarttab | |
set expandtab " substitute <tab> with spaces | |
set shiftround " use multiple of shiftwidth when indenting | |
" with '<' and '>' | |
set ruler " show line number and column number in status bar | |
set showcmd " show partial commands | |
set showmode " show current mode in status bar | |
set scrolloff=7 " set 7 lines to cursor - when moveing | |
" vertically using j/k | |
set laststatus=2 " always show the status line | |
set lazyredraw " only redraws if it is needed | |
set statusline=\ %<%F[%1*%M%*%n%R%H]%=\ %y\ %0(%{&fileformat}\ %{&encoding}\ %c:%l/%L%)\ | |
"====================================== | |
" Utility | |
"====================================== | |
set history=500 | |
set undofile | |
set undoreload=500 " permanent undo levels | |
set undodir=~/.vim/tmp/undo/ | |
set wildignore=*.o,*~,*.pyc,*.class | |
set hlsearch " highlight matched contents when search | |
set ignorecase " ignore case when searching | |
set smartcase " ignore case if search pattern is all lowercase, | |
" case-sensitive otherwise | |
set incsearch " instant searching | |
" auto complete brackets | |
function ClosePair(char) | |
if getline('.')[col('.') - 1] == a:char | |
return "\<Right>" | |
else | |
return a:char | |
endif | |
endf | |
:inoremap ( ()<ESC>i | |
:inoremap ) <c-r>=ClosePair(')')<CR> | |
:inoremap { {}<ESC>i | |
:inoremap } <c-r>=ClosePair('}')<CR> | |
:inoremap [ []<ESC>i | |
:inoremap ] <c-r>=ClosePair(']')<CR> | |
":inoremap < <><ESC>i | |
":inoremap > <c-r>=ClosePair('>')<CR> | |
:inoremap " ""<ESC>i | |
:inoremap ' ''<ESC>i | |
:inoremap ` ``<ESC>i | |
set wildmenu | |
set wildmode=list:longest,full | |
set wildignore+=*.sw? " Vim swap files | |
set wildignore+=*.bak,*.?~,*.??~,*.???~,*.~ " backup files | |
set wildignore+=*.pyc " Python byte code | |
set wildignore+=*.class " Java byte code | |
set wildignore+=*.jar " Java archives | |
set wildignore+=*.stats " Pylint stats | |
set wildignore+=*.jpg,*,png,*.jif | |
set wildignore+=*.dll,*.o,*.obj,*.exe | |
" A buffer becomes hidden when it is abandoned | |
set hidden | |
set wildmode=list:longest | |
set ttyfast | |
set completeopt=longest,menu,preview | |
inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<CR>" | |
inoremap <expr> <Down> pumvisible() ? "\<C-n>" : "\<Down>" | |
inoremap <expr> <Up> pumvisible() ? "\<C-n>" : "\<Up>" | |
inoremap <expr> <PageDown> pumvisible() ? "\<PageDown>\<C-p>\<C-n>" : "\<PageDown>" | |
inoremap <expr> <PageUp> pumvisible() ? "\<PageUp>\<C-p>\<C-n>" : "\<PageUp>" | |
"====================================== | |
" Plugins | |
"====================================== | |
" ---- NERDTree | |
map <F2> :NERDTreeToggle<CR> " toggle NERDTree with <F2> | |
" close vim if the only window left open is a NERDTree | |
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif | |
" ---- minibuffexpl | |
let g:miniBufExplMapWindowNavVim = 1 | |
let g:miniBufExplMapWindowNavArrows = 1 | |
let g:miniBufExplMapCTabSwitchBufs = 1 | |
let g:miniBufExplModSelTarget = 1 | |
" ---- taglist | |
map <F1><ESC> :!ctags -R *<CR> " run ctags with <F1> | |
map <f9> :TlistToggle<CR> " toggle taglist with <F9> | |
let Tlist_Show_One_File=1 | |
let Tlist_Exit_OnlyWindow=1 | |
let Tlist_Use_Right_Window=1 | |
let Tlist_File_Fold_Auto_Close=1 | |
let Tlist_Auto_Open = 0 | |
let Tlist_Auto_Update = 1 | |
let Tlist_Hightlight_Tag_On_BufEnter = 1 | |
let Tlist_Enable_Fold_Column = 0 | |
let Tlist_Process_File_Always = 1 | |
let Tlist_Display_Prototype = 0 | |
let Tlist_Compact_Format = 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment