2013-07-04 01:39:44 -07:00
|
|
|
|
" vim:cc=79,39
|
2015-03-09 10:02:16 -07:00
|
|
|
|
" make vim unusable for anyone else
|
|
|
|
|
|
2013-07-04 01:39:44 -07:00
|
|
|
|
set nocompatible " screw vi
|
2013-07-03 15:03:54 -07:00
|
|
|
|
|
2013-07-04 01:39:44 -07:00
|
|
|
|
if has('multi_byte')
|
|
|
|
|
scriptencoding utf-8 " allow it in this script
|
|
|
|
|
set termencoding=utf-8 " and this terminal supports it
|
|
|
|
|
set encoding=utf-8 " and the default file is in it
|
2013-07-03 15:03:54 -07:00
|
|
|
|
endif
|
|
|
|
|
|
2015-03-08 15:59:44 -07:00
|
|
|
|
" awful things
|
|
|
|
|
if has("win32")
|
|
|
|
|
let msys='/MinGW/msys/1.0/bin'
|
|
|
|
|
let &shell=msys.'/bash.exe'
|
|
|
|
|
set shellcmdflag=-c
|
|
|
|
|
set shellxquote=\"
|
|
|
|
|
set shellslash
|
|
|
|
|
|
|
|
|
|
" assume directory structure:
|
|
|
|
|
" something/anything/.vimrc " this was passed to vim by the -u switch
|
|
|
|
|
" something/vim/
|
|
|
|
|
" something/vim/after
|
|
|
|
|
let $MYVIMRC=expand('<sfile>')
|
|
|
|
|
let rcvim=expand('<sfile>:p:h:h').'/vim'
|
|
|
|
|
|
|
|
|
|
if !exists('win32_once')
|
|
|
|
|
let win32_once=1
|
|
|
|
|
let $PATH.=';'.msys
|
|
|
|
|
let &runtimepath=rcvim.','.&runtimepath.','.rcvim.'/after'
|
|
|
|
|
endif
|
|
|
|
|
else
|
2015-03-09 10:02:16 -07:00
|
|
|
|
let rcvim='~/.vim'
|
2015-03-08 15:59:44 -07:00
|
|
|
|
endif
|
|
|
|
|
|
2015-03-09 10:02:16 -07:00
|
|
|
|
let &backupdir=rcvim.'/backup' " stash tilde files elsewhere
|
|
|
|
|
" the double slash at the end dumps the path of the file for uniqueness
|
|
|
|
|
let &directory=rcvim.'/swp//' " screw swap files too
|
|
|
|
|
try | call mkdir(&backupdir, "p") | catch /E739/ | endtry
|
|
|
|
|
try | call mkdir(&directory, "p") | catch /E739/ | endtry
|
2015-03-08 15:59:44 -07:00
|
|
|
|
|
2013-07-04 01:39:44 -07:00
|
|
|
|
if (&term =~ "^xterm") " enable colors on any xterm
|
|
|
|
|
let &t_Co=256
|
|
|
|
|
let &t_AF="\e[38;5;%dm"
|
|
|
|
|
let &t_AB="\e[48;5;%dm"
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
if has('syntax')
|
|
|
|
|
syntax enable " required for folding as well
|
|
|
|
|
set hlsearch " highlight search results
|
|
|
|
|
endif
|
2013-07-03 15:03:54 -07:00
|
|
|
|
|
|
|
|
|
if has('gui_running')
|
2015-03-08 15:59:44 -07:00
|
|
|
|
set guioptions-=M " skip loading $VIMRUNTIME/menu.vim
|
|
|
|
|
set guioptions-=m " hide menu which isn't loaded anyway
|
2013-07-04 01:39:44 -07:00
|
|
|
|
set guioptions-=T " hide toolbar
|
2015-03-08 15:59:44 -07:00
|
|
|
|
set guioptions-=r " hide scrollbar
|
2013-07-04 01:39:44 -07:00
|
|
|
|
set guifont=Consolas:h9
|
|
|
|
|
set columns=84
|
|
|
|
|
set lines=36
|
|
|
|
|
cd $HOME " might not be ideal...
|
2015-03-08 15:59:44 -07:00
|
|
|
|
endif
|
2013-07-04 01:39:44 -07:00
|
|
|
|
|
2015-03-09 10:02:16 -07:00
|
|
|
|
try | colorscheme Tomorrow-Night | catch /E185/ | endtry
|
2013-07-03 15:03:54 -07:00
|
|
|
|
|
2015-03-08 15:59:44 -07:00
|
|
|
|
set colorcolumn=79
|
2013-07-03 15:03:54 -07:00
|
|
|
|
|
2013-07-04 01:39:44 -07:00
|
|
|
|
set history=512 " command lines to remember
|
|
|
|
|
|
|
|
|
|
set ruler " write out the cursor position
|
|
|
|
|
set lazyredraw " when executing macros, untyped things
|
|
|
|
|
|
|
|
|
|
if has('title')|set title|endif " terminal title
|
|
|
|
|
|
|
|
|
|
" be less verbose with some terms and tell vim to shut up
|
|
|
|
|
set shortmess=atI
|
|
|
|
|
|
|
|
|
|
" lower the priority of tab-completing files with these extensions
|
|
|
|
|
set suffixes=.bak,~,.swp,.o,.log,.out
|
|
|
|
|
|
|
|
|
|
set noerrorbells visualbell t_vb= " disable bells
|
|
|
|
|
|
|
|
|
|
set scrolloff=3 " row context during scrolling
|
|
|
|
|
set sidescrolloff=2 " col context during scrolling
|
|
|
|
|
|
|
|
|
|
set number " lines
|
|
|
|
|
let c_syntax_for_h=1 " use C highlighting for .h files
|
|
|
|
|
|
|
|
|
|
set incsearch " show first search result as we type
|
|
|
|
|
set ignorecase " insensitive searching
|
|
|
|
|
set smartcase " except when uppercase is used
|
2013-07-03 15:03:54 -07:00
|
|
|
|
|
2013-07-04 01:39:44 -07:00
|
|
|
|
set infercase " use existing case when ins-completing
|
2013-07-03 15:03:54 -07:00
|
|
|
|
|
2014-06-02 13:13:37 -07:00
|
|
|
|
set foldmethod=marker
|
2015-03-09 10:02:16 -07:00
|
|
|
|
set foldclose= " start with everything unfolded
|
2013-07-03 15:03:54 -07:00
|
|
|
|
|
2013-07-04 01:39:44 -07:00
|
|
|
|
if 0
|
|
|
|
|
set autoindent " when creating newline, use same indent
|
|
|
|
|
if has('smartindent')
|
|
|
|
|
set smartindent " automatic indents with a lot of stuff
|
|
|
|
|
endif
|
|
|
|
|
endif " it's really just annoying though
|
|
|
|
|
|
|
|
|
|
set diffopt+=iwhite " ignore whitespace in diff command
|
2013-07-03 15:03:54 -07:00
|
|
|
|
|
|
|
|
|
" word wrapping
|
|
|
|
|
set nowrap
|
|
|
|
|
set nolinebreak
|
|
|
|
|
|
2015-03-08 15:59:44 -07:00
|
|
|
|
set ffs=unix,dos " ffs indeed
|
|
|
|
|
|
2013-07-04 01:39:44 -07:00
|
|
|
|
set tabstop=8 shiftwidth=8 smarttab " 8 space tabs
|
|
|
|
|
|
2013-07-04 02:07:41 -07:00
|
|
|
|
fu! TabFour()
|
2015-03-09 10:02:16 -07:00
|
|
|
|
setlocal tabstop=8 shiftwidth=4 expandtab softtabstop=4
|
2013-07-04 02:07:41 -07:00
|
|
|
|
endf
|
2013-07-04 01:39:44 -07:00
|
|
|
|
|
2014-03-13 10:15:09 -07:00
|
|
|
|
fu! TabTwo()
|
|
|
|
|
setlocal tabstop=2 shiftwidth=2 expandtab
|
|
|
|
|
endf
|
|
|
|
|
|
2013-07-04 01:39:44 -07:00
|
|
|
|
if has('autocmd')
|
|
|
|
|
augroup tabs " 4 spaces as tabs for various languages
|
|
|
|
|
au!
|
2015-03-05 06:48:51 -08:00
|
|
|
|
au FileType bash,sh,zsh,mk,awk,python,pyrex,lua,vim call TabFour()
|
2013-07-04 01:39:44 -07:00
|
|
|
|
au BufRead,BufNewFile *.json call TabFour()
|
2014-03-13 10:15:09 -07:00
|
|
|
|
au BufRead,BufNewFile PKGBUILD call TabTwo()
|
2014-06-02 06:54:57 -07:00
|
|
|
|
au FileType ruby call TabTwo()
|
2014-03-13 10:15:09 -07:00
|
|
|
|
augroup END
|
|
|
|
|
|
2015-03-08 15:59:44 -07:00
|
|
|
|
augroup fuckbells " good lord vim you are archaic
|
|
|
|
|
au GUIEnter * set vb t_vb=
|
|
|
|
|
augroup END
|
|
|
|
|
|
2014-03-13 10:15:09 -07:00
|
|
|
|
augroup reload " http://superuser.com/a/417997
|
|
|
|
|
au!
|
|
|
|
|
au BufWritePost .vimrc,_vimrc,vimrc so $MYVIMRC
|
2013-07-04 01:39:44 -07:00
|
|
|
|
augroup END
|
|
|
|
|
|
2013-07-04 02:07:41 -07:00
|
|
|
|
fu! ResCur() " attempt to preserve cursor position
|
|
|
|
|
if line("'\"") > 1 && line("'\"") <= line("$")
|
|
|
|
|
normal! g`"
|
|
|
|
|
return 1
|
|
|
|
|
endif
|
|
|
|
|
endf
|
|
|
|
|
augroup resCur
|
|
|
|
|
au!
|
2013-07-08 17:45:51 -07:00
|
|
|
|
au BufWinEnter * call ResCur()
|
2013-07-04 02:07:41 -07:00
|
|
|
|
augroup END
|
2013-07-04 01:39:44 -07:00
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
set backspace=eol,start,indent " make backspace useful
|
|
|
|
|
|
2015-03-09 10:02:16 -07:00
|
|
|
|
" tab completion in command-line
|
|
|
|
|
if has('wildmenu') | set wildmenu | endif
|
2015-03-05 10:10:22 -08:00
|
|
|
|
|
2013-07-04 01:39:44 -07:00
|
|
|
|
" easy indent/unindent
|
|
|
|
|
nn <tab> >>
|
|
|
|
|
nn <s-tab> <<
|
|
|
|
|
" indentation without ending selection
|
|
|
|
|
vn <silent> <tab> >gv
|
|
|
|
|
vn <silent> <s-tab> <gv
|
2013-07-03 15:03:54 -07:00
|
|
|
|
|
2013-07-04 01:39:44 -07:00
|
|
|
|
" might make return useful
|
|
|
|
|
"nn <s-cr> J
|
|
|
|
|
"nn <c-cr> dd
|
|
|
|
|
" oh wait, terminals don't do that...
|
|
|
|
|
|
2015-03-09 10:02:16 -07:00
|
|
|
|
fu! Inn(q)
|
|
|
|
|
let args=split(a:q, '^\s*\(<[^>]\+>\s\+\)\+\zs')
|
|
|
|
|
exec 'nn '.args[0].' '.args[1]
|
|
|
|
|
exec 'ino '.args[0].' <c-o>'.args[1]
|
|
|
|
|
endf
|
|
|
|
|
com! -nargs=+ Inn call Inn(<q-args>)
|
|
|
|
|
|
|
|
|
|
Inn <F5> :w<cr>
|
|
|
|
|
Inn <F8> :e<cr>
|
|
|
|
|
Inn <F10> :bd<cr>
|
|
|
|
|
Inn <c-F5> :w!<cr>
|
|
|
|
|
Inn <c-F8> :e!<cr>
|
|
|
|
|
Inn <c-F10> :bd!<cr>
|
|
|
|
|
Inn <s-F5> :wall<cr>
|
|
|
|
|
Inn <s-F8> :tab ball<cr>
|
|
|
|
|
Inn <s-F10> :qall<cr>
|
2015-03-05 10:10:22 -08:00
|
|
|
|
|
|
|
|
|
" good habits
|
2015-03-09 10:02:16 -07:00
|
|
|
|
Inn <c-up> <c-y>
|
|
|
|
|
Inn <c-down> <c-e>
|
|
|
|
|
Inn <silent> <c-s-up> :m-2<cr>
|
|
|
|
|
Inn <silent> <c-s-down> :m+1<cr>
|
|
|
|
|
|
|
|
|
|
" hide search highlighting
|
|
|
|
|
Inn <silent> <c-]> :nohls<enter>
|
2013-07-04 01:39:44 -07:00
|
|
|
|
|
|
|
|
|
" rebind annoying things
|
2015-03-05 10:10:22 -08:00
|
|
|
|
" reflow text
|
2013-07-04 01:39:44 -07:00
|
|
|
|
nn Q gq
|
2015-03-05 10:10:22 -08:00
|
|
|
|
" split lines (opposite of J)
|
|
|
|
|
nn K i<cr><esc>k$
|
2015-03-05 11:57:16 -08:00
|
|
|
|
vn K <nop>
|
2015-03-05 12:40:32 -08:00
|
|
|
|
" follow tag
|
|
|
|
|
nn <bar> <c-]>
|
2015-03-06 07:14:33 -08:00
|
|
|
|
" delete line
|
|
|
|
|
nn D dd
|
|
|
|
|
|
2015-03-09 10:02:16 -07:00
|
|
|
|
" this frees up x and X for use if you like
|
2015-03-06 07:14:33 -08:00
|
|
|
|
set <s-Del>=[3;2~
|
|
|
|
|
nn <s-Del> X
|
|
|
|
|
|
|
|
|
|
" unfollow your leaders
|
2015-03-09 10:02:16 -07:00
|
|
|
|
"ino <c-\> <C-o><Leader>
|
2015-03-06 07:14:33 -08:00
|
|
|
|
nn <Leader>p "0p
|
|
|
|
|
nn <Leader>P "0P
|
|
|
|
|
nn <Leader>e :tabe
|
2015-03-07 07:57:26 -08:00
|
|
|
|
nn <Leader>. @:
|
|
|
|
|
"nn <Leader>x :!chmod +x % | e " how to end shell command?
|
2013-07-04 01:39:44 -07:00
|
|
|
|
|
|
|
|
|
if v:version < 703 " even debian stable has 7.3, so...
|
|
|
|
|
set nomodeline
|
|
|
|
|
else
|
|
|
|
|
if &termencoding == "utf-8"
|
|
|
|
|
set list listchars=tab:»·,trail:·,extends:…,nbsp:‗
|
|
|
|
|
else
|
|
|
|
|
set list listchars=tab:>-,trail:.,extends:>,nbsp:_
|
|
|
|
|
endif
|
|
|
|
|
endif
|
2015-03-05 10:10:22 -08:00
|
|
|
|
|
2015-03-09 10:02:16 -07:00
|
|
|
|
try | execute pathogen#infect() | catch /E117/ | endtry
|