You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

149 lines
4.0 KiB

" sourced by Janus
set tabstop=4
set shiftwidth=4
set softtabstop=4
autocmd FileType * map ,t :w<CR>
map ,m :w\|:make<CR><CR>
map ,- :nohl<CR>
" Set the indent to 2 when working with ruby and markup stuff
autocmd BufNew,BufRead *.feature,*.rb,*.ru,*.xml,*.html,*.htm,Gemfile,Rakefile,Procfile set shiftwidth=2
\| set tabstop=2
\| set softtabstop=2
autocmd FileType ruby set shiftwidth=2
\| set tabstop=2
\| set softtabstop=2
\| map ,t :RuboCop<CR>:w<CR>
autocmd FileType ruby map ,r :RuboCop<CR>
autocmd BufNew,BufRead *.ino,*.pde setf arduino
autocmd FileType arduino set tabstop=4
\| set softtabstop=4
\| let g:syntastic_cpp_check_header=0
\| map ,t :w<CR>:execute '!astyle' shellescape(expand('%'), 1)<CR>:e<CR>:make<CR><CR><CR>
" Set up some sane java compilation bits
autocmd BufNew,BufRead *.java set efm=%A\ %#[javac]\ %f:%l:\ %m,%-Z\ %#[javac]\ %p^,%-C%.%#
\| set makeprg=ant\ -find\ build.xml
" never expand tabs (multiline-strings) and remap ',t' to do :Fmt first in Go
autocmd FileType go set noexpandtab
\| map ,t :Fmt<CR>:w<CR>
" add color column for a few file types
autocmd FileType go,python,ruby set colorcolumn=80
" highlighting sbt as scala, too
autocmd BufNew,BufRead *.sbt set syn=scala
" (en|dis)able crosshairs!
function! EnableCrosshairs()
set cursorline
set cursorcolumn
highlight CursorLine ctermbg=blue
highlight CursorColumn ctermbg=blue
endfunction
function! DisableCrosshairs()
set nocursorline
set nocursorcolumn
endfunction
" MyNext() and MyPrev(): Movement between tabs OR buffers
function! MyNext()
if exists('*tabpagenr') && tabpagenr('$') != 1
" Tab support && tabs open
normal gt
else
" No tab support, or no tabs open
execute ":bnext"
endif
endfunction
function! MyPrev()
if exists('*tabpagenr') && tabpagenr('$') != '1'
" Tab support && tabs open
normal gT
else
" No tab support, or no tabs open
execute ":bprev"
endif
endfunction
" moving between tabs OR buffers
nnoremap L :call MyNext()<CR>
nnoremap H :call MyPrev()<CR>
" astyle the whole thing
map ,a :execute '!astyle' shellescape(expand('%'), 1)<CR>:e<CR>
" easy indentation in visual mode
" This keeps the visual selection active after indenting.
" Usually the visual selection is lost after you indent it.
vmap > >gv
vmap < <gv
" run make
" <F3> or \m
map <silent><F3> :make<CR>
map <silent><leader>m :make<CR>
" Highlight over 80 chars wide for python files
" (to call manually, use the mapping '\py80'
map <silent><leader>py80 :call LambastOver80Wide()<CR>
function! LambastOver80Wide()
highlight NearLength ctermbg=yellow ctermfg=black
match NearLength /\%76v.*/
highlight OverLength ctermbg=red ctermfg=white guibg=#592929
match OverLength /\%81v.*/
endfun
" disable mapping (to call manually use mapping '\nopy80'
map <silent><leader>nopy80 :call DisableLambastOver80Wide()<CR>
function! DisableLambastOver80Wide()
highlight OverLength ctermbg=Black ctermfg=white guibg=#000000
endfun
" call it right away for certain files
autocmd FileType python call LambastOver80Wide()
autocmd FileType moin call LambastOver80Wide()
" autocmd FileType go call LambastOver80Wide()
" autocmd FileType javascript call LambastOver80Wide()
" autocmd FileType actionscript call LambastOver80Wide()
autocmd FileType mail call LambastOver80Wide()
autocmd FileType scons call LambastOver80Wide()
" autocmd FileType cs call LambastOver80Wide()
" strip trailing whitespace
map <silent><leader>SW :call StripTrailingWhitespace()<CR>
function! StripTrailingWhitespace()
:%s/\s\+$//e
endfun
" remove all ^M chars
map <silent><leader>SM :call StripCtrlMs()<CR>
function! StripCtrlMs()
:%s/[ \t\r]\+$//e
endfun
" insert date
map <silent><leader>D :call InsertDate()<CR>
function! InsertDate()
:read !date
endfun
if !has('gui_running')
set t_Co=256
"colorscheme gardener
"colorscheme inkpot
colorscheme molokai
endif
let g:valgrind_arguments='--leak-check=yes --num-callers=50'