Skip to content

Instantly share code, notes, and snippets.

@flyingoctopus
Created May 15, 2017 17:14
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 flyingoctopus/e31a1aa5f0f6b6324ac33cc4adb2c592 to your computer and use it in GitHub Desktop.
Save flyingoctopus/e31a1aa5f0f6b6324ac33cc4adb2c592 to your computer and use it in GitHub Desktop.
set t_Co=256
filetype off
"call pathogen#runtime_append_all_bundles()
filetype plugin indent on
set nocompatible
" Security
set modelines=0
" Tabs/spaces
set tabstop=2
set shiftwidth=2
set softtabstop=2
set expandtab
" Basic options
set relativenumber
set encoding=utf-8
set scrolloff=3
set autoindent
set showmode
set showcmd
set hidden
set wildmenu
set wildmode=list:longest
set visualbell
set cursorline
set ttyfast
set ruler
set backspace=indent,eol,start
set laststatus=2
set formatoptions=l
set lbr
set clipboard=unnamed
" Enable code completion
filetype plugin on
set ofu=syntaxcomplete#Complete
au Bufread,BufNewFile *.as set filetype=actionscript
" Backups
"set backupdir=~/.vim/tmp/backup// " backups
"set directory=~/.vim/tmp/swap// " swap files
set backup " enable backups
" Searching
nnoremap / /\v
vnoremap / /\v
set ignorecase
set smartcase
set incsearch
set showmatch
set hlsearch
set gdefault
map <leader><space> :noh<cr>
runtime macros/matchit.vim
nmap <tab> %
vmap <tab> %
"" Soft/hard wrapping
set wrap
set textwidth=79
set formatoptions=qrn1
" /usr/share/terminfo/xColor scheme (terminal)
syntax on
"set background=dark
"colorscheme sorcerer
colorscheme molokai
"colorscheme mustang
set printfont=InputSansCondensed:h12
if has("gui_running")
if has("gui_gtk2")
set guifont=Inconsolata\ 12
elseif has("gui_macvim")
set guifont=InputSansCondensed:h12
elseif has("gui_win32")
set guifont=Consolas:h11:cANSI
endif
endif
" Dashapp
map <F6> :Dash<cr>
" NERD Tree
map <F1> :NERDTreeToggle %:p:h<cr>
let NERDTreeIgnore=['.vim$', '\~$', '.*\.pyc$', 'pip-log\.txt$']
autocmd FileType nerdtree setlocal relativenumber
autocmd FileType taglist setlocal relativenumber
" Use the damn hjkl keys
nnoremap <up> <nop>
nnoremap <down> <nop>
nnoremap <left> <nop>
nnoremap <right> <nop>
" And make them fucking work, too.
nnoremap j gj
nnoremap k gk
" Easy buffer navigation
map <C-h> <C-w>h
map <C-j> <C-w>j
map <C-k> <C-w>k
map <C-l> <C-w>l
map <leader>w <C-w>v<C-w>l
" Folding
set foldlevelstart=0
nnoremap <Space> za
vnoremap <Space> za
au BufNewFile,BufRead *.html map <leader>ft Vatzf
"function! MyFoldText()
"let line = getline(v:foldstart)
"let nucolwidth = &fdc + &number * &numberwidth
"let windowwidth = winwidth(0) - nucolwidth - 3
"let foldedlinecount = v:foldend - v:foldstart
"" expand tabs into spaces
"let onetab = strpart(' ', 0, &tabstop)
"let line = substitute(line, '\t', onetab, 'g')
"let line = strpart(line, 0, windowwidth - 2 -len(foldedlinecount))
"let fillcharcount = windowwidth - len(line) - len(foldedlinecount) - 4
"return line . '…' . repeat(" ",fillcharcount) . foldedlinecount . '…' . ' '
"endfunction
"set foldtext=MyFoldText()
" Various syntax stuff
au BufNewFile,BufRead *.less set filetype=less
au BufRead,BufNewFile *.scss set filetype=scss
au BufRead,BufNewFile *.confluencewiki set filetype=confluencewiki
au BufRead,BufNewFile *.confluencewiki set wrap linebreak nolist
"au BufNewFile,BufRead *.md filetype=markdown
au BufNewFile,BufRead *.md nnoremap <leader>1 yypVr=
au BufNewFile,BufRead *.md nnoremap <leader>2 yypVr-
au BufNewFile,BufRead *.md nnoremap <leader>3 I### <ESC>
au BufNewFile,BufRead *.m*down set filetype=markdown
au BufNewFile,BufRead *.m*down nnoremap <leader>1 yypVr=
au BufNewFile,BufRead *.m*down nnoremap <leader>2 yypVr-
au BufNewFile,BufRead *.m*down nnoremap <leader>3 I### <ESC>
" Sort CSS
map <leader>S ?{<CR>jV/^\s*\}?$<CR>k:sort<CR>:noh<CR>
" Clean whitespace
map <leader>W :%s/\s\+$//<cr>:let @/=''<CR>
"" Tags!
"" Exuberant ctags!
let Tlist_Ctags_Cmd = "/usr/local/bin/ctags"
let Tlist_WinWidth = 50
map <F7> :TlistToggle<cr>
map <F8> :!/usr/local/bin/ctags -R --c++-kinds=+p --fields=+iaS --extra=+q --exclude='@.ctagsignore' .<cr>
let Tlist_Show_One_File = 1
"map <F4> :TlistToggle<cr>
map <leader>T :!/usr/local/bin/ctags --exclude='**/ckeditor' -R . <CR>
" Ack
map <leader>a :Ack
" Yankring
nnoremap <silent> <F3> :YRShow<cr>
nnoremap <silent> <leader>y :YRShow<cr>
" Formatting, TextMate-style
map <leader>q gqip
"nmap <leader>m :make<cr>
nnoremap <F9> :SClangStart
" Google's JSLint
au BufNewFile,BufRead *.js set makeprg=gjslint\ %
au BufNewFile,BufRead *.js set errorformat=%-P-----\ FILE\ \ :\ \ %f\ -----,Line\ %l\\,\ E:%n:\ %m,%-Q,%-GFound\ %s,%-GSome\ %s,%-Gfixjsstyle%s,%-Gscript\ can\ %s,%-G
" Use Node.js for JavaScript interpretation
let $JS_CMD='node'
" TESTING GOAT APPROVES OF THESE LINES
au BufNewFile,BufRead test_*.py set makeprg=nosetests\ --machine-out\ --nocapture
au BufNewFile,BufRead test_*.py set shellpipe=2>&1\ >/dev/null\ \|\ tee
au BufNewFile,BufRead test_*.py set errorformat=%f:%l:\ %m
au BufNewFile,BufRead test_*.py nmap <silent> <Leader>n <Plug>MakeGreen
au BufNewFile,BufRead test_*.py nmap <Leader>N :make<cr>
nmap <silent> <leader>ff :QFix<cr>
nmap <leader>fn :cn<cr>
nmap <leader>fp :cp<cr>
command -bang -nargs=? QFix call QFixToggle(<bang>0)
function! QFixToggle(forced)
if exists("g:qfix_win") && a:forced == 0
cclose
unlet g:qfix_win
else
copen 10
let g:qfix_win = bufnr("$")
endif
endfunction
"" TODO: Put this in filetype-specific files
au BufNewFile,BufRead *.less set foldmethod=marker
au BufNewFile,BufRead *.less set foldmarker={,}
au BufNewFile,BufRead *.less set nocursorline
"au BufRead,BufNewFile /etc/nginx/conf/* set ft=nginx
"au BufRead,BufNewFile /etc/nginx/sites-available/* set ft=nginx
"au BufRead,BufNewFile /usr/local/etc/nginx/sites-available/* set ft=nginx
" Easier linewise reselection
map <leader>v V`]
" Dash lookup
nmap <leader>D :Dash<CR>
" HTML tag closing
inoremap <C-_> <Space><BS><Esc>:call InsertCloseTag()<cr>a
" Faster Esc
"inoremap <Esc> <nop>
inoremap jj <ESC>
" Scratch
nmap <leader><tab> :Scratch<cr><C-W>x<C-j>:resize 15<cr>
" Make selecting inside an HTML tag less dumb
nnoremap Vit vitVkoj
" Diff
nmap <leader>d :!git diff %<cr>
" Golang!
au FileType go nmap <leader>gor <Plug>(go-run)
au FileType go nmap <leader>gob <Plug>(go-build)
au FileType go nmap <leader>got <Plug>(go-test)
au FileType go nmap <leader>goc <Plug>(go-coverage)
" Rainbows!
nmap <leader>R :RainbowParenthesesToggle<CR>
" Edit .vimrc
nmap <leader>ev <C-w><C-v><C-l>:e $MYVIMRC<cr>
nmap <leader>ev <C-w><C-v><C-l>:e ~/.vimrc.after<cr>
" Sudo to write
cmap w!! w !sudo tee % >/dev/null
" Easy filetype switching
nnoremap _dt :set ft=htmldjango<CR>
nnoremap _jt :set ft=htmljinja<CR>
nnoremap _cw :set ft=confluencewiki<CR>
nnoremap _sc:set ft=supercollider<CR>
""
"" HALP
nnoremap _wtfcw :!open 'http://confluence.atlassian.com/renderer/notationhelp.action?section=all'<cr>
cabbrev h tab h
"" VCS Stuff
"let VCSCommandMapPrefix = "<leader>h"
"" Disable useless HTML5 junk
"let g:event_handler_attributes_complete = 0
"let g:rdfa_attributes_complete = 0
"let g:microdata_attributes_complete = 0
"let g:atia_attributes_complete = 0
" Shouldn't need shift
nnoremap ; :
" Save when losing focus
au FocusLost * :wa
" Stop it, hash key
inoremap # X<BS>#
"" Cram tests
"au BufNewFile,BufRead *.t set filetype=cram
"let cram_fold=1
"autocmd Syntax cram setlocal foldlevel=1
"" Show syntax highlighting groups for word under cursor
"nmap <C-S> :call SynStack()<CR>
"function! SynStack()
"if !exists("*synstack")
"return
"endif
"echo map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")')
"endfunc
" ConqueTerm
"map <leader>e :call StartTermVSplit()<CR>
" ConqueTerm wrapper
function StartTermVSplit()
let g:ConqueTerm_Color = 1
execute 'ConqueTermVSplit ' . $SHELL . ' --login'
setlocal listchars=tab:\ \
endfunction
" Command-/ to toggle comments
map <leader>/ <plug>NERDCommenterToggle<CR>
" Command-][ to increase/decrease indentation
vmap <leader>[ >gv
vmap <leader>] <gv
if has('gui_running')
source ~/.gvimrc.after
endif
"autocmd bufenter * cd %:p:h
" set Processing Doc path
let processing_doc_path="/Applications/Processing.app/Contents/Resources/Java/reference/"
" supercollider source
so ~/.scvimrc
"if $TERM == 'screen'
set term=xterm-256color
"endif
au BufRead,BufNewFile *.pde setf java
au VimLeave * :!clear
function DeleteHiddenBuffers()
let tpbl=[]
call map(range(1, tabpagenr('$')), 'extend(tpbl, tabpagebuflist(v:val))')
for buf in filter(range(1, bufnr('$')), 'bufexists(v:val) && index(tpbl, v:val)==-1')
silent execute 'bwipeout' buf
endfor
endfunction
" Toggle relative/absolute line numbers during edit
if exists('+relativenumber')
autocmd InsertEnter * setl nu
autocmd InsertLeave * setl rnu
endif
" wordpress stuff
if filereadable(expand("~/.vimrc.wordpress"))
sourc ~/.vimrc.wordpress
endif
" syntastic
"set statusline+=%#warningmsg#
"set statusline+=%{SyntasticStatuslineFlag()}
"set statusline+=%*
"let g:syntastic_always_populate_loc_list = 1
"let g:syntastic_auto_loc_list = 1
"let g:syntastic_check_on_open = 1
"let g:syntastic_check_on_wq = 0
" Change cursor shape between insert and normal mode in iTerm2.app
if $TERM_PROGRAM =~ "iTerm"
let &t_SI = "\<Esc>]50;CursorShape=1\x7" " Vertical bar in insert mode
let &t_EI = "\<Esc>]50;CursorShape=0\x7" " Block in normal mode
endif
" Ali: to indent json files on save
autocmd FileType json autocmd BufWritePre <buffer> %!python -m json.tool 2>/dev/null || echo <buffer>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment