Skip to content

Commit

Permalink
Added vim configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
lianhao committed Dec 10, 2015
1 parent 2b29049 commit 518f5bd
Showing 1 changed file with 97 additions and 0 deletions.
97 changes: 97 additions & 0 deletions vim/.vimrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
" The following is from
" https://realpython.com/blog/python/vim-and-python-a-match-made-in-heaven

" Vundle(VIM plugin manager) related.
" Must before anything else
" $ git clone https://github.com/gmarik/Vundle.vim.git ~/.vim/bundle/Vundle.vim
set nocompatible " required
filetype off " required

" 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'
" Add all your plugins here (note older versions of Vundle used Bundle
" instead of Plugin)
Plugin 'tmhedberg/SimpylFold'
Plugin 'vim-scripts/indentpython.vim'
Plugin 'Valloric/YouCompleteMe'
Plugin 'scrooloose/syntastic'
Plugin 'nvie/vim-flake8'
Plugin 'Lokaltog/powerline', {'rtp': 'powerline/bindings/vim/'}
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required

" Split window below & right
set splitbelow
set splitright
" Split navigation
nnoremap <C-J> <C-W><C-J>
nnoremap <C-K> <C-W><C-K>
nnoremap <C-L> <C-W><C-L>
nnoremap <C-H> <C-W><C-H>
" Turn on spelling check
setlocal spell spelllang=en
hi SpellBad term=underline cterm=underline ctermfg=0 ctermbg=7 gui=underline guibg=LightGrey


" Enable code folding with spacebar
set foldmethod=indent
set foldlevel=99
nnoremap <space> za
" See docstrings for folded code
let g:SimpylFold_docstring_preview=1

" PEP8 indentation for python
au BufNewFile,BufRead *.py
\ set tabstop=4 |
\ set softtabstop=4 |
\ set shiftwidth=4 |
\ set textwidth=79 |
\ set expandtab |
\ set autoindent |
\ set fileformat=unix |

" Other indentation
au BufNewFile,BufRead *.js, *.html, *.css
\ set tabstop=2 |
\ set softtabstop=2 |
\ set shiftwidth=2 |

highlight BadWhitespace ctermbg=red guibg=darkred
" Display tabs at the beginning of a line in Python mode as bad.
au BufRead,BufNewFile *.py,*.pyw match BadWhitespace /^\t\+/
" Flagging unnecessary whitespace
au BufRead,BufNewFile *.py,*.pyw,*.c,*.h match BadWhitespace /\s\+$/

" UTF8 support
set encoding=utf-8

" Auto-Completion & goto defintion
let g:ycm_autoclose_preview_window_after_completion=1
map <leader>g :YcmCompleter GoToDefinitionElseDeclaration<CR>
" Python with virtualenv support
py << EOF
import os
import sys
if 'VIRTUAL_ENV' in os.environ:
project_base_dir = os.environ['VIRTUAL_ENV']
activate_this = os.path.join(project_base_dir, 'bin/activate_this.py')
execfile(activate_this, dict(__file__=activate_this))
EOF

" Make code looks more pretty
let python_highlight_all=1
" Turn on syntax coloring & automatically indentation
syntax on
filetype plugin on
filetype indent plugin on

0 comments on commit 518f5bd

Please sign in to comment.