Last active
August 29, 2015 14:16
-
-
Save GoSteven/d4c4807c43aac9a59e2b to your computer and use it in GitHub Desktop.
Vimrc
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
set nocompatible | |
filetype off | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => Vundle https://github.com/gmarik/Vundle.vim | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" set the runtime path to include Vundle and initialize | |
set rtp+=~/.vim/bundle/Vundle.vim | |
call vundle#begin() | |
" alternatively, pass a path where Vundle should install plugins | |
"call vundle#begin('~/some/path/here') | |
" let Vundle manage Vundle, required | |
Plugin 'gmarik/Vundle.vim' | |
" ctrlp, search files | |
Plugin 'kien/ctrlp.vim' | |
" Automatic syntax checker for Python | |
"Plugin 'andviro/flake8-vim' | |
" Tabular | |
Plugin 'vim-scripts/Tabular' | |
Plugin 'GoSteven/nerdtree' | |
Plugin 'chrisbra/changesPlugin' | |
Plugin 'vim-scripts/vcscommand.vim' | |
Plugin 'vim-scripts/taglist-plus' | |
Plugin 'GoSteven/bufexplorer' | |
Plugin 'GoSteven/python-syntax' | |
Plugin 'davidhalter/jedi-vim' | |
Plugin 'hynek/vim-python-pep8-indent' | |
" Javascript syntax check | |
"Plugin 'wookiehangover/jshint.vim' | |
"Plugin 'Shutnik/jshint2.vim' | |
Plugin 'scrooloose/syntastic' | |
Plugin 'pangloss/vim-javascript' | |
Plugin 'skwp/greplace.vim' | |
" The following are examples of different formats supported. | |
" Keep Plugin commands between vundle#begin/end. | |
" plugin on GitHub repo | |
"Plugin 'tpope/vim-fugitive' | |
" plugin from http://vim-scripts.org/vim/scripts.html | |
"Plugin 'L9' | |
" Git plugin not hosted on GitHub | |
"Plugin 'git://git.wincent.com/command-t.git' | |
" git repos on your local machine (i.e. when working on your own plugin) | |
"Plugin 'file:///home/gmarik/path/to/plugin' | |
" The sparkup vim script is in a subdirectory of this repo called vim. | |
" Pass the path to set the runtimepath properly. | |
Plugin 'rstacruz/sparkup', {'rtp': 'vim/'} | |
" Avoid a name conflict with L9 | |
"Plugin 'user/L9', {'name': 'newL9'} | |
" All of your Plugins must be added before the following line | |
call vundle#end() " required | |
filetype plugin indent on " required | |
" To ignore plugin indent changes, instead use: | |
"filetype plugin on | |
" | |
" Brief help | |
" :PluginList - list configured plugins | |
" :PluginInstall(!) - install (update) plugins | |
" :PluginSearch(!) foo - search (or refresh cache first) for foo | |
" :PluginClean(!) - confirm (or auto-approve) removal of unused plugins | |
" | |
" see :h vundle for more details or wiki for FAQ | |
" Put your non-Plugin stuff after this line | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => Personal | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
syntax on | |
set background=dark | |
map <space> : | |
map <C-j> <C-w><down> | |
map <C-k> <C-w><up> | |
map <C-h> <C-w><left> | |
map <C-l> <C-w><right> | |
imap <C-j> <down> | |
imap <C-k> <up> | |
imap <C-h> <left> | |
imap <C-l> <right> | |
let mapleader=";" | |
map <leader>w :w!<cr> | |
map <leader>q :close<cr> | |
map <leader>[ <C-o> | |
map <leader>] <C-]> | |
map <leader><space> <C-w> | |
map <leader>j :bn<cr> | |
nmap <tab> :b#<cr> | |
map <leader>k :bp<cr> | |
map <leader>bd :bd<cr> | |
map <leader>tn :tabnew<cr> | |
"map <leader>l :tabn<cr> | |
"map <leader>h :tabp<cr> | |
map <C-t> :tabnew<cr> | |
map <C-tab> :tabn<cr> | |
map <C-S-tab> :tabp<cr> | |
map <leader>tl :TlistToggle<cr> | |
map <leader>gf :NERDTree<cr> | |
set mouse=a | |
set history=500 | |
set ts=4 | |
set expandtab | |
set listchars=tab:>- | |
set list | |
set smarttab | |
set shiftwidth=4 | |
set autoindent | |
set smartindent | |
set cindent | |
set scrolloff=3 | |
set wildmenu | |
set cmdheight=1 | |
set ruler | |
set number | |
set hid | |
set whichwrap+=<,>,h,l | |
set ignorecase | |
set smartcase | |
set incsearch | |
set magic | |
set showmatch | |
set hlsearch | |
set laststatus=2 | |
"set statusline=\ %P\ %F%m%r%h\ %y\ %w\ \ CWD:\ %{getcwd()}%h\ \ Line:\ %l/%L:%c | |
"set statusline=\ %P\ %F%m%r%h\ %y\ %w\ \ \ Line:\ %l/%L:%c | |
set showmode | |
if &diff | syntax off | endif " no Syntax highting in vimdiff | |
function! InsertStatuslineColor(mode) | |
if a:mode == 'i' | |
hi statusline guibg=magenta | |
elseif a:mode == 'r' | |
hi statusline guibg=blue | |
else | |
hi statusline guibg=red | |
endif | |
endfunction | |
au InsertEnter * call InsertStatuslineColor(v:insertmode) | |
au InsertLeave * hi statusline guibg=green | |
" default the statusline to green when entering Vim | |
hi statusline guibg=green | |
"setlocal spell spelllang=en_us | |
map <leader>ss :setlocal spell!<cr> | |
map <leader>ii :set diffopt+=iwhite<cr> | |
"""""""""""""""""""""""""""""" | |
" => Status line | |
"""""""""""""""""""""""""""""" | |
" Always show the status line | |
set laststatus=2 | |
" Format the status line | |
set statusline=\ %f%m%r%h\ %w\ \ %<%=CWD:%{getcwd()}\ \ Line:\ %l/%L:%c | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => Easy Select Buffers | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
nnoremap <silent> <F6> :BufExplorer<CR> | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => Shell output to temp buffer | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
""the code commented below works but will cause segmentation fault when 'gf' | |
"function! s:ExecuteInShell(command) " {{{ | |
" let command = join(map(split(a:command), 'expand(v:val)')) | |
" let winnr = bufwinnr('^' . command . '$') | |
" silent! execute winnr < 0 ? 'botright vnew ' . fnameescape(command) : winnr . 'wincmd w' | |
" setlocal buftype=nowrite bufhidden=wipe nobuflisted noswapfile nowrap nonumber | |
" echo 'Execute ' . command . '...' | |
" silent! execute 'silent %!'. command | |
" silent! redraw | |
" silent! execute 'au BufUnload <buffer> execute bufwinnr(' . bufnr('#') . ') . ''wincmd w''' | |
" silent! execute 'nnoremap <silent> <buffer> <LocalLeader>r :call <SID>ExecuteInShell(''' . command . ''')<CR>:AnsiEsc<CR>' | |
" silent! execute 'nnoremap <silent> <buffer> q :q<CR>' | |
" silent! execute 'AnsiEsc' | |
" echo 'Shell command ' . command . ' executed.' | |
"endfunction " }}} | |
"command! -complete=shellcmd -nargs=+ Shell call s:ExecuteInShell(<q-args>) | |
"nnoremap <leader>! :Shell | |
function! s:RunShellCommand(cmdline) | |
botright new | |
setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile nowrap | |
call setline(1,a:cmdline) | |
call setline(2,substitute(a:cmdline,'.','=','g')) | |
execute 'silent $read !'.escape(a:cmdline,'%#') | |
setlocal nomodifiable | |
1 | |
endfunction | |
command! -complete=shellcmd -nargs=+ Shell call s:RunShellCommand(<q-args>) | |
map ! :Shell | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => display change | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
:let g:changes_autocmd=0 | |
:let g:changes_vcs_check=1 | |
:let g:changes_vcs_system='bzr' | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => display SVN log of a revision | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
fun! ShowLog() | |
let s:revision = expand('<cword>') | |
:exe "VCSLog " . s:revision | |
endfun | |
fun! ShowSVNDiff() | |
let s:revision = expand('<cword>') | |
let s:revision_prev = substitute(s:revision,"r","","g") - "1" | |
:exe "VCSVimDiff " . s:revision_prev . " " . s:revision | |
endfun | |
map <leader>M :call ShowLog()<CR><CR> | |
map <leader>D :call ShowSVNDiff()<CR> | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => auto fold | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
set foldmethod=syntax | |
set foldlevelstart=90 | |
let javaScript_fold=1 " JavaScript | |
let perl_fold=1 " Perl | |
let php_folding=1 " PHP | |
let r_syntax_folding=1 " R | |
let ruby_fold=1 " Ruby | |
let sh_fold_enabled=1 " sh | |
let vimsyn_folding='af' " Vim script | |
let xml_syntax_folding=1 " XML | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => vim template | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
autocmd BufNewFile *.py 0r ~/.vim/template/simple.py | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => CtrlP settings | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
let g:ctrlp_working_path_mode = '' | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => Syntastidc | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
set statusline+=%#warningmsg# | |
set statusline+=%{SyntasticStatuslineFlag()} | |
set statusline+=%* | |
"let g:syntastic_always_populate_loc_list = 1 | |
"let g:syntastic_auto_loc_list = 1 | |
"let g:syntastic_check_on_open = 1 | |
let g:syntastic_check_on_wq = 1 | |
let g:syntastic_javascript_checkers = ['jshint'] | |
let g:syntastic_python_checkers = ['flake8'] | |
function! ToggleErrors() | |
let old_last_winnr = winnr('$') | |
lclose | |
if old_last_winnr == winnr('$') | |
" Nothing was closed, open syntastic error location panel | |
Errors | |
endif | |
endfunction | |
map <leader>ee :call ToggleErrors()<cr> | |
function! ToggleQuickFix() | |
let old_last_winnr = winnr('$') | |
cclose | |
if old_last_winnr == winnr('$') | |
" Nothing was closed, open syntastic error location panel | |
copen | |
endif | |
endfunction | |
map <leader>cc :call ToggleQuickFix()<cr> | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => Ctrl+N for Jedi completion | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
"let g:jedi#completions_command = "<C-N>" | |
:set timeout timeoutlen=3000 ttimeoutlen=100 | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => key map navigate quickfix | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
nnoremap <c-n> :cn<CR> | |
nnoremap <leader><c-p> :cprev<CR> | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => find usage of word under cursor | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
map <leader>u :execute "vimgrep /\\<" . expand("<cword>") . "\\>/gj **" <Bar> cw <CR> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment