Skip to content

Instantly share code, notes, and snippets.

@ngleader
Created September 30, 2014 01:10
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 ngleader/28fea0312c5086d3acb4 to your computer and use it in GitHub Desktop.
Save ngleader/28fea0312c5086d3acb4 to your computer and use it in GitHub Desktop.
.vimrc (Tools for PHP)
set t_Co=256
"let mapleader = ","
" for Vundle
set nocompatible " be iMproved
filetype off " required!
set rtp+=~/.vim/bundle/vundle/
call vundle#begin()
" let Vundle manage Vundle
Plugin 'gmarik/Vundle.vim' " required!
"Plugin 'The-NERD-tree'
"Plugin 'taglist-plus'
"Plugin 'https://github.com/terryma/vim-multiple-cursors.git'
"Plugin 'joonty/vim-phpqa.git'
call vundle#end() " required
filetype plugin indent on " required
" for Vundle
" for Korean
set encoding=utf-8
set termencoding=utf-8
" for visual
syntax enable
"set background=dark
"colorscheme solarized
set go-=L " Removes left hand scroll bar
set linespace=15
set nu " Line numbers on
set nowrap " Line wrapping off
set ts=4 " Tabs are 2 spaces
"set bs=4 " Backspace over everything in insert mode
set shiftwidth=4 " Tabs under smart indent
set autoindent
set smarttab
set showmode " always show what mode we're currently editing in
set smarttab
set expandtab " expand tabs by default (overloadable per file type later)
set shiftround " use multiple of shiftwidth when indenting with '<' and '>'
set backspace=indent,eol,start " allow backspacing over everything in insert mode
set autoindent " always set autoindenting on
set copyindent " copy the previous indentation on autoindenting
set ignorecase " ignore case when searching
set smartcase " ignore case if search pattern is all lowercase,
set timeout timeoutlen=200 ttimeoutlen=100
set visualbell " don't beep
set noerrorbells " don't beep
set autowrite "Save on buffer switch
"change current directory
nnoremap <leader>cd :cd %:p:h<CR>:pwd<CR>
" Visual
set mat=5 " Bracket blinking.
set hlsearch
highlight Search cterm=underline
" use mouse
"set mouse=a
"autocmd cursorhold * set nohlsearch
"autocmd cursormoved * set hlsearch
" tag
set tags=.php.tags
" Resize vsplit
nmap <leader>25 :vertical resize 40<cr>
nmap <leader>50 <c-w>=
nmap <leader>75 :vertical resize 120<cr>
" Plugin taglist
let Tlist_Use_Right_Window=1
nmap <leader>t :TlistToggle<cr>
" Plugin NERDTree
nmap <leader>l :NERDTreeToggle<cr>
autocmd VimEnter * NERDTree " auto start
" Plugin phpqa
"let g:phpqa_php_cmd='/usr/bin/php'
"let g:phpqa_codesniffer_cmd='/usr/bin/phpcs'
" Don't run messdetector on save (default = 1)
let g:phpqa_messdetector_autorun = 0
" Don't run codesniffer on save (default = 1)
let g:phpqa_codesniffer_autorun = 0
" Show code coverage on load (default = 0)
let g:phpqa_codecoverage_autorun = 0
" Prepare a new PHP class
function! Class()
let name = input('Class name? ')
let namespace = input('Any Namespace? ')
if strlen(namespace)
exec "normal i<?php namespace " . namespace . ";\<C-m>\<C-m>"
else
exec "normal i<?php \<C-m>"
endif
" Open class
exec "normal iclass " . name . " {\<C-m>}\<C-[>O\<C-[>"
exec "normal i\<C-M>public function __construct()\<C-M>{\<C-M>\<C-M>}\<C-[>"
endfunction
nmap <leader>n :call Class()<CR>
nmap <leader>s :!clear && php -l %<CR>
" Auto-remove trailing spaces
autocmd BufWritePre *.php :%s/\s\+$//e
" Phpunit
function! RunPHPUnitTest(filter)
cd %:p:h
if a:filter
normal! T yw
let result = system("/home/xedev/vimforphp/demo/phpunit/vendor/bin/phpunit --filter " . @" . " " . bufname("%"))
else
let result = system("/home/xedev/vimforphp/demo/phpunit/vendor/bin/phpunit " . bufname("%"))
endif
split __PHPUnit_Result__
normal! ggdG
setlocal buftype=nofile
call append(0, split(result, '\v\n'))
cd -
endfunction
nnoremap <leader>u :call RunPHPUnitTest(0)<cr>
nnoremap <leader>f :call RunPHPUnitTest(1)<cr>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment