Skip to content

Instantly share code, notes, and snippets.

@Altreus
Created November 14, 2013 11:04
Show Gist options
  • Save Altreus/7465020 to your computer and use it in GitHub Desktop.
Save Altreus/7465020 to your computer and use it in GitHub Desktop.
syntax on
set mouse=a
set background=dark
set showmatch
set showcmd
set ai
set tabstop=4
set foldcolumn=3
"set expandtab
let &shiftwidth=&softtabstop
set nu
set viminfo='10,\"100,:20,n~/.viminfo
au BufReadPost * if line("'\"") > 0|if line("'\"") <= line("$")|exe("norm '\"")|else|exe "norm $"|endif|endif
au BufReadPost *COMMIT_EDITMSG :1
if has("gui_running")|color golden|endif
"highlight Comment guifg=darkblue ctermfg=darkblue
set guifont=DejaVu\ Sans\ Mono\ 10
set go-=T
set go-=m
set go+=c
set t_Co=256
set statusline=%-10.(%l:%L\ %c[%v]%)\ \ %<%r%{FindSub()}\ \ %=%m%f\ \ %{GitBranchInfoTokens()[0]}
autocmd FileType php :noremap K :!php --rf <cword><CR>
autocmd FileType php set foldlevel=10
let php_folding=1
autocmd FileType php set omnifunc=phpcomplete#CompletePHP
autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
autocmd FileType php,html autocmd! BufWritePre <buffer> :%s/\s\+$//e
" set incremental searching with highlight
set incsearch
if &t_Co > 2 || has("gui_running")
set hlsearch
endif
cnoreabbrev W w
map <F1> :w !php -l %<CR>
map <F2> <C-W>+
map <F3> <C-W>-
map <F4> <C-W>_
map <F5> <C-W>=
map <F6> :W<CR>
map <F9> <C-W>>
map <F10> <C-W><
map <F11> zM
map <F12> zR
map <F7> "*p
imap <F7> <C-o>"*p
map <S-F7> "*P
imap <S-F7> <C-o>"*P
nmap F zc
nmap f zo
imap <C-l> <C-x><C-o>
xmap <F12> :call CComment()<CR>
nmap + :LargerFont<CR>
nmap - :SmallerFont<CR>
map [[ [{
map ]] ]}
map ,, :m+1<CR>
map ^^ :m-2<CR>
nmap <Leader>d "_d
nmap <Leader>x "_x
nmap <Leader>c "_c
nmap <Leader>s "_s
nmap <Leader>r "_r
nmap <Leader>D "_D
nmap <Leader>X "_X
nmap <Leader>C "_C
nmap <Leader>S "_S
vmap <Leader>d "_d
vmap <Leader>c "_c
vmap <Leader>x "_x
vmap <Leader>s "_s
vmap <Leader>r "_r
highlight Folded term=standout guifg=lightblue guibg=#000025
highlight Comment ctermfg=darkgray
hi MatchParen NONE
hi MatchParen term=underline cterm=underline gui=underline
command! -range Cat set nonu | <line1>,<line2>p | set nu
function! CComment() range
call cursor(a:lastline, 1)
norm o*/
call cursor(a:firstline, 1)
/* norm O
endfunction
let s:pattern = '^\(.* \)\([1-9][0-9]*\)$'
let s:minfontsize = 6
let s:maxfontsize = 16
function! AdjustFontSize(amount)
if has("gui_gtk2") && has("gui_running")
let fontname = substitute(&guifont, s:pattern, '\1', '')
let cursize = substitute(&guifont, s:pattern, '\2', '')
let newsize = cursize + a:amount
if (newsize >= s:minfontsize) && (newsize <= s:maxfontsize)
let newfont = fontname . newsize
let &guifont = newfont
endif
else
echoerr "You need to run the GTK2 version of Vim to use this function."
endif
endfunction
function! LargerFont()
call AdjustFontSize(1)
endfunction
command! LargerFont call LargerFont()
function! SmallerFont()
call AdjustFontSize(-1)
endfunction
command! SmallerFont call SmallerFont()
function! FindSub()
let subpattern = '\(sub\|function\) \w\+'
let subline = search(subpattern, 'bnW')
if !subline
return 'not in sub'
else
return matchstr(getline(subline), subpattern)
endif
endfunction
function! s:DiffWithSaved()
let filetype=&ft
diffthis
vnew | r # | normal! 1Gdd
diffthis
exe "setlocal bt=nofile bh=wipe nobl noswf ro ft=" . filetype
endfunction
com! DiffSaved call s:DiffWithSaved()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment