Skip to content

Instantly share code, notes, and snippets.

@xpcoffee
Last active August 13, 2018 19:25
Show Gist options
  • Save xpcoffee/2979df338cef907e22a42419a338c91d to your computer and use it in GitHub Desktop.
Save xpcoffee/2979df338cef907e22a42419a338c91d to your computer and use it in GitHub Desktop.
personal vimrc file 2018-08
" Author: Emerick Bosch
" Date Last Updated: August 2018
"""""""""""
" Plugins "
"""""""""""
" ---- Vundle header start ----
set nocompatible " used iMproved mode (required by Vundle)
filetype off " required by Vundle
" set runtime path to include Vundle
set rtp+=~/.vim/bundle/Vundle.vim
" initialize
call vundle#begin()
" ---- Vundle header end ----
" core
Plugin 'gmarik/Vundle.vim'
Plugin 'scrooloose/nerdtree'
" movement
Plugin 'Lokaltog/vim-easymotion'
" input
Plugin 'tpope/vim-surround'
" syntax
Plugin 'vim-syntastic/syntastic'
" colour
Plugin 'chriskempson/base16-vim'
" autocompletion
Plugin 'Valloric/YouCompleteMe'
" status bar
Plugin 'bling/vim-airline'
Plugin 'vim-airline/vim-airline-themes'
" git
Plugin 'tpope/vim-fugitive'
Plugin 'kien/ctrlp.vim'
" ---- Vundle footer start ----
call vundle#end() " required by Vundle
filetype plugin indent on
" ---- Vundle footer end ----
""""""""""""""""
" Key Bindings "
""""""""""""""""
" leader: the special character with which to start commands
let mapleader=","
" edit .vimrc
nnoremap <leader>v :e ~/.vimrc<CR>
" source .vimrc
nnoremap <leader>o :so %<CR>
map <space> <Plug>(easymotion-prefix)
" run ruby
nnoremap <leader>r :!/usr/bin/env ruby %<CR>
" edit .vimrc
nnoremap <Left> :bp<CR>
" edit .vimrc
nnoremap <Right> :bn<CR>
" source rc file
nnoremap <leader>s :so ~/.vimrc<CR>:nohl<CR>
" automatic bracket completion in INSERT mode
inoremap {<Enter> {<Enter>}<Esc>O<Tab>
" remap ctrl-F to autocomplete file-names in INSERT mode
inoremap <C-f> <C-x><C-f>
" NERDTree
nnoremap <Up> :NERDTreeToggle<CR>
nnoremap <Down> :NERDTreeFind<CR>
" Speed up ctrl p
let g:ctrlp_user_command = ['.git', 'cd %s && git ls-files . --cached --exclude-standard']
" FKeys
nnoremap <F10> :nohl<CR>
""""""""""""""
" Appearance "
""""""""""""""
set showmatch " show matching bracket
set number " line numbers
set scrolloff=20 " scroll to keep cursor # lines from screen edge
set laststatus=2 " always show file path
syntax on " syntax highlighting
set list
set listchars=tab:>- " show tab characters
set cursorline " highlight the line the cursor is on
" Read the colorscheme file provided by base16 shell
" see also https://github.com/chriskempson/base16-shell#base16-vim-users
if filereadable(expand("~/.vimrc_background"))
let base16colorspace=256
source ~/.vimrc_background
endif
"""""""""
" Input "
"""""""""
" keyboard
set whichwrap+=<,>,h,l " h and l will wrap to the next/previsous line
" mouse
set mouse=a " allow mouse-click
" indentations
set smarttab " makes tabs at the beginning of a line an indent
set shiftwidth=4 " size of indent
set tabstop=4 " size of tab
set autoindent " new line has indent of previous line
set expandtab " converts tabs to spaces
" line wraping
set textwidth=0 " don't automatically wrap lines
" autocompletion
set wildmenu " tab-completion in command-mode
set wildmode=longest,list " filename completion, show list if many
""""""""""""""""""""""""""""""
" Searching and highlighting "
""""""""""""""""""""""""""""""
" within buffer
set incsearch " incremental search
set hlsearch " highlight all matches
" vim grep
set grepprg=ag\ --nogroup\ --nocolor
set grepformat=%f:%l:%c:%m
" speed up the ctrl-P by using the silver searcher
" see also https://github.com/ggreer/the_silver_searcher
let g:ctrlp_cache_dir = $HOME . '/.cache/ctrlp'
let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""'
""""""""""""""""""""""""""""""""""""
" Text formatting and manipulation "
""""""""""""""""""""""""""""""""""""
fun! TrimWhitespace()
let l:save = winsaveview()
%s/\s\+$//e
call winrestview(l:save)
endfun
autocmd BufWritePre * :call TrimWhitespace() " trim whitespace before saving
" correct line endings etc
set fileformat=unix
" format json - requires python
command FormatJSON %!python -m json.tool
"""""""""""""""
" Performance "
"""""""""""""""
set lazyredraw " no output while running macro
set ttyfast " better redrawing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment