Skip to content

Instantly share code, notes, and snippets.

@jay-johnson
Created September 22, 2018 20:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jay-johnson/d7116ced6e6514f6923eb17ee57dc3ad to your computer and use it in GitHub Desktop.
Save jay-johnson/d7116ced6e6514f6923eb17ee57dc3ad to your computer and use it in GitHub Desktop.
vimrc file for python
"2016-11-10 v1 - start"
" set tabstop=4
" set shiftwidth=4
" set smartindent
" set pastetoggle=<F10>
"2016-11-10 v1 - end"
"2016-11-10 v2 - start"
set pastetoggle=<F10>
set autoindent " always set autoindenting on"
set smartindent " use smart indent if there is no indent file"
set tabstop=4 " <tab> inserts 4 spaces"
set softtabstop=4 " <BS> over an autoindent deletes 4 spaces."
set smarttab " Handle tabs more intelligently"
set expandtab " Use spaces, not tabs, for autoindent/tab key."
set shiftwidth=4 " an indent level is 4 spaces wide."
set shiftround " rounds indent to a multiple of shiftwidth"
set showmode
set hlsearch
augroup auto_comment
au!
au FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o
augroup END
"2016-11-10 v2 - end"
"2018-01-02 start"
"
" Taken from:
" https://realpython.com/blog/python/vim-and-python-a-match-made-in-heaven/
"
set encoding=utf-8
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)
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
"split navigations
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>
" Enable folding
set foldmethod=indent
set foldlevel=99
" Enable folding with the spacebar
nnoremap <space> za
Plugin 'tmhedberg/SimpylFold'
let g:SimpylFold_docstring_preview=1
au BufNewFile,BufRead "*.py" set tabstop=4 set softtabstop=4 set shiftwidth=4 set textwidth=79 set expandtab set autoindent set fileformat=unix
au BufNewFile,BufRead "*.js, *.html, *.css" set tabstop=2 set softtabstop=2 set shiftwidth=2
Plugin 'vim-scripts/indentpython.vim'
au BufRead,BufNewFile "*.py,*.pyw,*.c,*.h" match BadWhitespace /\s\+$/
Bundle 'Valloric/YouCompleteMe'
"python with virtualenv support
"py << EOF
"import os
"import sys
"if 'VENV_DIR' in os.environ:
" project_base_dir = os.environ['VENV_DIR']
" activate_this = os.path.join(project_base_dir, 'bin/activate_this.py')
" execfile(activate_this, dict(__file__=activate_this))
"EOF
let g:ycm_autoclose_preview_window_after_completion=1
" On a method/class/function if you use:
" g + g it will go-to that code... super helpful navigate
map gg :YcmCompleter GoToDefinitionElseDeclaration<CR>
"Plugin 'vim-syntastic/syntastic'
Plugin 'nvie/vim-flake8'
Plugin 'jnurmine/Zenburn'
" Plugin 'altercation/vim-colors-solarized'
" https://github.com/bcicen/vim-jfmt
Plugin 'bcicen/vim-jfmt'
let g:jfmt_autofmt = 1
if has('gui_running')
set background=dark
colorscheme solarized
call togglebg#map("<F5>")
" else
" colorscheme zenburn
endif
Plugin 'scrooloose/nerdtree'
Plugin 'jistr/vim-nerdtree-tabs'
let NERDTreeIgnore=['\.pyc$', '\~$'] "ignore files in NERDTree
Plugin 'kien/ctrlp.vim'
Plugin 'tpope/vim-fugitive'
Plugin 'Lokaltog/powerline', {'rtp': 'powerline/bindings/vim/'}
Plugin 'davidhalter/jedi-vim'
let python_highlight_all=1
syntax on
Plugin 'flazz/vim-colorschemes'
Plugin 'heavenshell/vim-pydocstring'
map ga :call pydocstring#insert()<CR>
autocmd FileType python setlocal tabstop=4 shiftwidth=4 softtabstop=4 expandtab
autocmd BufWritePost *.py call Flake8()
" Yaml file handling
autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab
filetype plugin indent on
autocmd FileType yaml setl indentkeys-=<:>
" Copy paste with ctr+c, ctr+v, etc
:behave mswin
:set clipboard=unnamedplus
:smap <Del> <C-g>"_d
:smap <C-c> <C-g>y
:smap <C-x> <C-g>x
:imap <C-v> <Esc>pi
:smap <C-v> <C-g>p
:smap <Tab> <C-g>1>
:smap <S-Tab> <C-g>1<
"2018-01-02 end"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment