Skip to content

Instantly share code, notes, and snippets.

@cmsj
Created February 11, 2015 11:25
Show Gist options
  • Save cmsj/423c4a23fc006d6d93c6 to your computer and use it in GitHub Desktop.
Save cmsj/423c4a23fc006d6d93c6 to your computer and use it in GitHub Desktop.
" Be iMproved
set nocompatible
filetype off
set rtp+=~/.vim/bundle/vundle
call vundle#rc()
" Bundles
Bundle 'gmarik/vundle'
Bundle 'kien/ctrlp.vim'
Bundle 'tpope/vim-fugitive'
Bundle 'mattn/gist-vim'
Bundle 'airblade/vim-gitgutter'
Bundle 'sjl/gundo.vim'
Bundle 'davidhalter/jedi-vim'
Bundle 'scrooloose/nerdtree'
Bundle 'scrooloose/syntastic'
Bundle 'majutsushi/tagbar'
Bundle 'mattn/webapi-vim'
Bundle 'vim-scripts/YankRing.vim'
Bundle 'bling/vim-airline'
Bundle 'jnurmine/Zenburn'
Bundle 'greyblake/vim-preview'
Bundle 'darfink/vim-plist'
filetype plugin indent on
" Detect the system
let os=substitute(system('uname'), '\n', '', '')
if os == 'Darwin' || os == 'Mac'
let platform='mac'
elseif os == 'Linux'
let platform='linux'
else
let platform='unknown'
endif
" Enable 256 colours if we can
" FIXME: This should go away in favour of us setting TERM properly in
" Terminator1.0
if $TERM == "xterm-256color" || $TERM == "screen-256color" || $COLORTERM == "gnome-terminal"
set t_Co=256
endif
" If we have colour support, take advantage of it
if &t_Co > 2 || has("gui_running")
" Load that colourscheme we like
colorscheme zenburn
" Enable syntax highlighting
syntax on
endif
" Enable indenting
filetype plugin indent on
" Be sure that VIM knows we want Unicode
:set encoding=utf-8
" Set our default preferred tab/space behaviours
:set expandtab tabstop=4 shiftwidth=4 softtabstop=4
" Add a paste toggle that works in normal/insert modes
:set pastetoggle=<F9>
" Show enough of a status line for Airline to appear
:set laststatus=2
" Search as you type
:set incsearch
" Ignore case when searching
:set ignorecase
" Don't ignore case when searching if upper case characters are used
:set smartcase
" Highlight search matches
:set hlsearch
" Show line numbers by default
:set number
" Remember lots of command history
:set history=100
" Configure our mapleader
:let mapleader="\<Space>"
" Enable persistent undo
:set undodir=~/.cache/vim/undodir
:set undofile
:set undolevels=1000
:set undoreload=10000
" Show whitespace characters (except an actual space)
:set listchars=eol:¶,tab:»-,trail:·
:set list
" Keep some scroll offset
:set scrolloff=5
" Toggle line numbers
:nmap <leader>l :setlocal number!<CR>
" Toggle paste mode
:nmap <leader>p :set paste!<CR>
" Clear highlighted search matches
":nmap <leader>q :nohlsearch<CR>
" Toggle whitespace characters
:nmap <leader>c :set list!<CR>
" Vertical split
:nmap <leader>d :vsplit
" Horizontal split
:nmap <leader>D :split
" Toggle this buffer and the last buffer
:nmap <C-e> :e#<CR>
" Next buffer
:nmap <C-n> :bnext<CR>
" Previous buffer
:nmap <C-p> :bprev<CR>
" Switch between various hatefully incorrect tab/space formats
:nmap <leader>t :set expandtab tabstop=4 shiftwidth=4 softtabstop=4<CR>
:nmap <leader>T :set expandtab tabstop=8 shiftwidth=8 softtabstop=4<CR>
:nmap <leader>M :set noexpandtab tabstop=8 softtabstop=4 shiftwidth=4<CR>
:nmap <leader>m :set expandtab tabstop=2 shiftwidth=2 softtabstop=2<CR>
" Remap macro recording away from q, to <leader>q
nnoremap <leader>q q
nnoremap q <Nop>
" Configure Airline's look
let g:airline_left_sep='▶'
let g:airline_right_sep='◀'
let g:airline_linecolumn_prefix = '␊ '
let g:airline_theme='dark'
" Integrate Airline with other plugins
let g:airline_enable_branch=1
let g:airline_enable_syntastic=1
" NOTE: There is no more specific python syntax/linting because syntastic can
" do it if you pip install flake8
" Make syntastic check when opening a file
:let g:syntastic_check_on_open=1
" Fancy syntastic error/warning symbols
let g:syntastic_error_symbol='✗'
let g:syntastic_warning_symbol='⚠'
" Limit syntastic location list window height
let g:syntastic_loc_list_height=4
" Make NERDTree close when we open a file
let g:NERDTreeQuitOnOpen=1
" Open NERDTree to browse for files
:nmap <leader>e :NERDTreeToggle<CR>
" Open Tagbar
:nmap <leader>x :TagbarToggle<CR>
" Open CtrlP
let g:ctrlp_map='<leader>b'
" Show the Buffer browser by default
let g:ctrlp_cmd='CtrlPBuffer'
" Configure Gist platform integration
if platform == 'mac'
let g:gist_clip_command='pbcopy'
let g:gist_browser_command='open %URL%'
elseif platform == 'linux'
let g:gist_clip_command='xclip -selection clipboard'
let g:gist_browser_command='x-www-browser %URL%'
endif
" Detect Gist filetypes
let g:gist_detect_filetype=1
" Open Gist in a browser after posting
let g:gist_open_browser_after_post=1
" Include private Gists in list
let g:gist_show_privates=1
" Post private Gists by default
let g:gist_post_private=1
" Map a shortcut to open the Gundo browser
noremap <leader>u :GundoToggle<CR>
" Show gundo on the right
let g:gundo_right=1
" Configure bindings for fugitive
map <leader>gd :Gdiff<CR>
map <leader>gs :Gstatus<CR>
map <leader>gb :Gblame<CR>
map <leader>gc :Gcommit<CR>
map <leader>gca :Gcommit -a<CR>
" Configure bindings for YankRing
map <leader>y :YRShow<CR>
let g:yankring_history_file = '.vim/yankring_history'
" Configure bindings for Preview
map <leader>h :Preview<CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment