Skip to content

Instantly share code, notes, and snippets.

@jakehasler
Last active October 31, 2016 03:46
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 jakehasler/7eb5eeafd71d79f2330a7b48266e60db to your computer and use it in GitHub Desktop.
Save jakehasler/7eb5eeafd71d79f2330a7b48266e60db to your computer and use it in GitHub Desktop.
Jake's .vimrc - A Work in Progress
syntax on
colorscheme onedark
syntax enable
let mapleader = ' '
set number
set tabstop=2
set shiftwidth=2
set expandtab
set nowrap
set linebreak
set t_Co=16
set nobackup
set nowritebackup
set noswapfile
set incsearch
set wildmenu
set fileformats=unix,dos,mac
set backspace=indent,eol,start
set mouse=a
set nocompatible
filetype plugin indent on
" Changes cursor type depending on the mode
if exists('$TMUX')
let &t_SI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=1\x7\<Esc>\\"
let &t_EI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=0\x7\<Esc>\\"
else
let &t_SI = "\<Esc>]50;CursorShape=1\x7"
let &t_EI = "\<Esc>]50;CursorShape=0\x7"
endif
autocmd InsertEnter * set cul
autocmd InsertLeave * set nocul
" yank to clipboard
if has("clipboard")
set clipboard=unnamed " copy to the system clipboard
if has("unnamedplus") " X11 support
set clipboard+=unnamedplus
endif
endif
" *** KEYBINDINGS ***
" Go to last active tab
nnoremap <C-H> <C-W>w
noremap <C-h> <C-w>h
noremap <C-j> <C-w>j
noremap <C-k> <C-w>k
noremap <C-l> <C-w>l
noremap H ^
noremap L $
" Map to make it easier to source vim config file
nnoremap <leader>sv :source $MYVIMRC<cr>
" Easily open up vim config
nnoremap <leader>ev :vsplit $MYVIMRC<cr>
" Select and tab now possible
vnoremap < <gv
vnoremap > >gv
" IO.inspect insertion on the page
imap ioo IO.inspect
" Console log from insert mode; Puts focus inside parentheses
imap cll console.log();<Esc>==f(a
" Console log from visual mode on next line, puts visual selection inside parentheses
vmap cll yocll<Esc>p
" " Console log from normal mode, inserted on next line with word your on inside parentheses
nmap cll yiwocll<Esc>p
" Formats JSON
com! FormatJSON %!python -m json.tool
" *** SETTINGS ***
" Setting: Highlight trailing whitespace
highlight ExtraWhitespace ctermbg=red guibg=red
match ExtraWhitespace /\s\+$/
autocmd BufWinEnter * match ExtraWhitespace /\s\+$/
autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
autocmd InsertLeave * match ExtraWhitespace /\s\+$/
" Setting: Italicize comments
let &t_ZH="\e[3m"
let &t_ZR="\e[23m"
highlight Comment cterm=italic
" Setting: Trim trailing spaces on save
function! TrimWhiteSpace()
let l = line(".")
let c = col(".")
%s/\s\+$//e
%s/\r//ge
call cursor(l, c)
endfunction
autocmd BufWritePre * :call TrimWhiteSpace()
" Setting: Allow me to paste multiple times
xnoremap p pgvy
" Automatically resize splits when window is resized
au VimResized * exe "normal! \<c-w>="
" *** PLUGINS ***
call plug#begin()
Plug 'tpope/vim-fugitive'
Plug 'jistr/vim-nerdtree-tabs'
Plug 'thoughtbot/pick.vim'
nnoremap <Leader>p :call PickFile()<CR>
nnoremap <Leader>s :call PickFileSplit()<CR>
nnoremap <Leader>v :call PickFileVerticalSplit()<CR>
nnoremap <Leader>t :call PickFileTab()<CR>
nnoremap <Leader>b :call PickBuffer()<CR>
nnoremap <Leader>] :call PickTag()<CR>
Plug 'scrooloose/nerdtree'
map <Leader>n <plug>NERDTreeTabsToggle<CR>
let g:pick_height = 10
Plug 'vim-scripts/tComment'
map <Leader>/ :TComment<CR>
map <CR> :TComment<CR>
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
noremap <Leader>g :GitGutterToggle<CR>
let g:airline_theme='badwolf'
let g:airline_powerline_fonts = 1
Plug 'airblade/vim-gitgutter'
Plug 'terryma/vim-multiple-cursors'
Plug 'pangloss/vim-javascript'
Plug 'mxw/vim-jsx'
let g:jsx_ext_required = 0
Plug 'mileszs/ack.vim'
let g:ackprg = 'ag --nogroup --column'
Plug 'elixir-lang/vim-elixir'
call plug#end()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment