Skip to content

Instantly share code, notes, and snippets.

@expelledboy
Last active February 15, 2017 09:50
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 expelledboy/20d2b1a63d8d44e95016 to your computer and use it in GitHub Desktop.
Save expelledboy/20d2b1a63d8d44e95016 to your computer and use it in GitHub Desktop.
vimrc
if !filereadable(expand('~/.vim/plugin/source.vim'))
silent !curl -fLo ~/.vim/plugin/source.vim --create-dirs https://raw.githubusercontent.com/suderman/source.vim/master/plugin/source.vim
endif
" load config from gists :D
runtime plugin/source.vim
Source https://gist.githubusercontent.com/expelledboy/20d2b1a63d8d44e95016/raw/cbe125eb002ccbca86f74474510219b03ddf590a/backups.vim
" automatically save before commands like :next and :make
set autowrite
" automatically read a file if changed outside of vim
set autoread
" you can accidently delete entire repos, so vcs are not a catch all
set backup
" persistent undos
set undofile
" use to keep all temporary and backup files in one place
let vh=$HOME.'/.vim'
let &backupdir=vh.'/backup'
let &directory=vh.'/tmp'
let &undodir=vh.'/undo'
let s:tempdirs = [ &directory, &backupdir, &undodir ]
" if needed create directories
for s:file in s:tempdirs
if !isdirectory(expand(s:file))
echo "creating " . s:file
call mkdir(expand(s:file), "p")
endif
endfor
" hit "u" in visual mode when I mean to "y", use "gu" instead
vnoremap u <nop>
vnoremap gu u
" heavy shift
command! -bang E e<bang>
command! -bang Q q<bang>
command! -bang W w<bang>
command! -bang QA qa<bang>
command! -bang Qa qa<bang>
command! -bang Wa wa<bang>
command! -bang WA wa<bang>
" quick save (remember to disable flow control)
nnoremap <C-s> :update<cr>
inoremap <C-s> <esc>:update<cr>
inoremap <C-b> <Left>
inoremap <C-f> <Right>
inoremap <C-e> <End>
inoremap <C-a> <Home>
cnoremap <C-a> <Home>
cnoremap <C-e> <End>
autocmd FileType erlang setlocal shiftwidth=2 tabstop=8
autocmd FileType erlang ab <= =<
" autocmd FileType erlang setlocal foldmethod=indent
" autocmd FileType erlang setlocal foldnestmax=1
autocmd FileType erlang setlocal commentstring=%%%s
if system('uname -s')=~'Darwin'
if has('gui_running')
let macvim_skip_cmd_opt_movement = 1
no <M-Left> <C-Left>
no! <M-Left> <C-Left>
no <M-Right> <C-Right>
no! <M-Right> <C-Right>
no <D-Up> <C-Home>
ino <D-Up> <C-Home>
no <M-Up> {
ino <M-Up> <C-o>{
no <D-Down> <C-End>
ino <D-Down> <C-End>
no <M-Down> }
ino <M-Down> <C-o>}
ino <M-BS> <C-w>
ino <D-BS> <C-u>
" copy iterms behaviours
noremap <D-Right> :tabnext<cr>
noremap <D-Left> :tabprevious<cr>
" moving in splits
nnoremap <silent> <D-]> <c-w>l
nnoremap <silent> <D-[> <c-w>h
endif
" so that we can use vim with crontab
set backupskip=/tmp/*,/private/tmp/*
endif
" improve massive macro performance
set lazyredraw
" quick macros
nnoremap Q @@
" logial home and end mappings
noremap H ^
noremap L $
" use space for leader
nnoremap <space> <nop>
let g:mapleader = "\<space>"
let mapleader = "\<space>"
" evaluate viml in current instance
autocmd FileType vim vnoremap <buffer> <leader>S y:execute @@<cr>:echo 'Sourced selection.'<cr>
autocmd FileType vim nnoremap <buffer> <leader>S ^vg_y:execute @@<cr>:echo 'Sourced line.'<cr>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment