Skip to content

Instantly share code, notes, and snippets.

@imme-emosol
Created December 6, 2010 22:47
Show Gist options
  • Save imme-emosol/731134 to your computer and use it in GitHub Desktop.
Save imme-emosol/731134 to your computer and use it in GitHub Desktop.
imavimrc -- my personal vimrc( w/ vim mostly used for php.)
" some things are probably in this file twice, some don't work.
" furthermore i expect the following files and directories to exist:
" ~/.vim/backups
" ~/.vim/swap_files
" ~/.vim/skeletons ( in it files: my.phtml my.php my.class.php my.js
" in the files certain character-sequences are expected, e.g. <CLASS_NAME>
" too find the other sequences and or places where these paths are used the following regex can be used
" (search for a regex in vim by typing a forward slash `/` in "normal mode",
" after that you can type the following( wihtout the leading double quote `"` and space ` ` of course):
" \~\/\.vim
se bg=dark
se completeopt=menu,longest,preview
se wildmenu
nmap ,w :w<CR>
se si
se ts=3 sw=3
se number
set nocompatible "Compatible with vi? Yeah, right!
"The following nnoremap( and accompanying comment) is in my ~/.vim_all_rc ,
" which also gets sourced by ~/.vimperatorrc for firefox' vimperator-addon
" To also do this, this might help you: source <sfile>:h/.vim_all_rc
" <C-h> (CTRL-h redraws the screen and inverts the current highlighting of the search.
nnoremap <silent> <C-h> :se invhlsearch<CR>
set encoding=utf-8
set termencoding=utf-8
set fileencoding=utf-8
"set guifontset=Courier\ New\ 10
set gfn=Courier\ 10\ Pitch\ 11
" {{{ Shortcuts / Mappings / Abbreviations :
map gf :e <cfile><CR>
"" Make [[ and ]] work even if the { is not in the first column
"nnoremap <silent> [[ :call search('^\S\@=.*{$', 'besW')<CR>
"nnoremap <silent> ]] :call search('^\S\@=.*{$', 'esW')<CR>
"onoremap <expr> [[ (search('^\S\@=.*{$', 'ebsW') && (setpos("''", getpos('.'))
" \ <bar><bar> 1) ? "''" : "\<ESC>")
"onoremap <expr> ]] (search('^\S\@=.*{$', 'esW') && (setpos("''", getpos('.'))
" \ <bar><bar> 1) ? "''" : "\<ESC>")
" CTRL-g shows filename and buffer number, too.
nnoremap <C-g> 2<C-g>
" use <Ctrl>+N/<Ctrl>+P to cycle through files:
nnoremap <C-N> :bnext<CR>
nnoremap <C-P> :bprev<CR>
" [<Ctrl>+N by default is like j, and <Ctrl>+P like k.]
" use <F6> to cycle through split windows (and <Shift>+<F6> to cycle backwards, where possible):
nnoremap <F6> <C-W>w
nnoremap <S-F6> <C-W>W
" Make shift-tab go to the previous cursor-position (By default Tab goes to the next)
nnoremap <S-Tab> <C-O>
" F10 toggles highlighting lines that are too long
nnoremap <F10> :call <SID>ToggleTooLongHL()<CR>
" F11 toggles line numbering
nnoremap <silent> <F11> :set number! <bar> set number?<CR>
" F12 toggles search term highlighting
nnoremap <silent> <F12> :set hlsearch! <bar> set hlsearch?<CR>
iabbr <silent> _dt <C-R>=strftime("%a\ %0Y-%0m-%0d,\ %0H:%0M.%0S\ %Z")<CR><C-R>=EatChar('\s')<CR>
ia <silent> TD @todo[~username, <C-R>=strftime("%a\ %0Y-%0m-%0d,\ %0H:%0M.%0S\ %Z")<CR>]<CR>
ia <silent> td @todo[~username, <C-R>=strftime("%a\ %0Y-%0m-%0d,\ %0H:%0M.%0S\ %Z")<CR>]<CR>
ia <silent> NT @note[~username, <C-R>=strftime("%a\ %0Y-%0m-%0d,\ %0H:%0M.%0S\ %Z")<CR>]<CR>
ia <silent> nt @note[~username, <C-R>=strftime("%a\ %0Y-%0m-%0d,\ %0H:%0M.%0S\ %Z")<CR>]<CR>
ia <silent> die( die();<Left><Left>
ia <silent> DS DIRECTORY_SEPARATOR<C-R>=EatChar('\s\')<CR>
ia <silent> retrun return
" {{{ Help-Buffer to the right , not the top. :
"autocmd BufEnter */vim/vim*/doc/* <C-W>L <C-W>J
"autocmd BufEnter * if &ft == 'help' | wincmd J | wincmd L | endif
cabbrev h botright vertical help
" / Help-Buffer to the right , not the top. }}}
" / Shortcuts / Mappings / Abbreviations }}}
" {{{ Graphical :
set background=dark " expect a DARK background.
"set cursorcolumn " highlight the current column
"set cursorline " highlight current line
set number " turn on line numbers
set numberwidth=5 " We are good up to 99999 lines
" {{{ Messages , Info , Status :
set vb t_vb= " Disable all bells. I hate ringing/flashing.
set confirm " Y-N-C prompt if closing with unsaved changes.
set showcmd " Show incomplete normal mode commands as I type. " display which command is initiated
set report=0 " : commands always print changed line count.
set shortmess+=a " Use [+]/[RO]/[w] for modified/readonly/written.
set ruler " Show some info, even without statuslines.
set laststatus=2 " Always show statusline, even if only 1 window.
"let &statusline = '%<%f%{&mod?"[+]":""}%r%'
" \ . '{&fenc !~ "^$\\|utf-8" || &bomb ? "[".&fenc.(&bomb?"-bom":"")."]" : ""}'
" \ . '%='
" \ . '%{exists("actual_curbuf")&&bufnr("")==actual_curbuf?CountMatches(1):""}'
" \ . '%15.(%l,%c%V %P%)'
" / Messages , Info , Status }}}
" {{{ Command-Line :
"set wildmenu " turn on command line completion wild style
set wildmenu " Menu completion in command mode on <Tab>
" have command-line completion <Tab> (for filenames, help topics, option names)
" first list the available options and complete the longest common part, then
" have further <Tab>s cycle through the possibilities:
set wildmode=list:longest,full " list:longest > turn on wild mode huge list
set wildignore=*.dll,*.o,*.obj,*.bak,*.exe,*.pyc,*.jpg,*.gif,*.png " ignore this list of file extensions
"set wcm=<C-Z> " Ctrl-Z in a mapping acts like <Tab> on cmdline
"source $VIMRUNTIME/menu.vim " Load menus (this would be done anyway in gvim)
"" <F4> triggers the menus, even in terminal vim.
"map <F4> :emenu <C-Z>
" / Command-Line }}}
" {{{ Windows, Buffers :
set noequalalways " Don't keep resizing all windows to the same size
set hidden " Hide modified buffers when they are abandoned
set swb=useopen,usetab " Allow changing tabs/windows for quickfix/:sb/etc
set splitright " New windows open to the right of the current one
map <Leader>1 :b 1<CR>
map <Leader>2 :b 2<CR>
map <Leader>3 :b 3<CR>
map <Leader>4 :b 4<CR>
map <Leader>5 :b 5<CR>
map <Leader>6 :b 6<CR>
map <Leader>7 :b 7<CR>
map <Leader>8 :b 8<CR>
map <Leader>9 :b 9<CR>
map <Leader>0 :b 10<CR>
" press gb to goto next buffer
map gb :bn<CR>
" press gB to goto prev buffer
map gB :bN<CR>
" / Windows & Buffers }}}
"if &enc =~ '^u\(tf\|cs\)' " When running in a Unicode environment,
" set list " visually represent certain invisible characters:
" let s:arr = nr2char(9655) " using U+25B7 (▷) for an arrow, and
" let s:dot = nr2char(8901) " using U+22C5 (⋅) for a very light dot,
" " display tabs as an arrow followed by some dots (▷⋅⋅⋅⋅⋅⋅⋅),
" exe "set listchars=tab:" . s:arr . s:dot
" " and display trailing and non-breaking spaces as U+22C5 (⋅).
" exe "set listchars+=trail:" . s:dot
" exe "set listchars+=nbsp:" . s:dot
" " Also show an arrow+space (↪ ) at the beginning of any wrapped long lines?
" " I don't like this, but I probably would if I didn't use line numbers.
" " let &sbr=nr2char(8618).' '
"endif
set listchars=eol:⚰,tab:⤜┈,trail:•,extends:↦,precedes:↤,nbsp:\ " how to show tabs and trailing
set list " show special-chars
" Set my statusline :
set statusline=%F%m%r%h%w%=[%L][%{&ff}]%y\ %4.8l,%-4.8v\ %p%%\
" | | | | | | | | | | | |
" | | | | | | | | | | | +-- current % into file
" | | | | | | | | | | + current column
" | | | | | | | | | +-- current line
" | | | | | | | | +-- current syntax in
" | | | | | | | | square brackets
" | | | | | | | +-- current fileformat
" | | | | | | +-- number of lines
" | | | | | +-- right-align all that follows
" | | | | +-- preview flag in square brackets
" | | | +-- help flag in square brackets
" | | +-- readonly flag in square brackets
" | +-- rodified flag in square brackets
" +-- full path to file in the buffer
se stl+=\ %{strftime(\"%0Y\ %0m\ %0d\ %0H:%0M.%0S%Z\")}
" |
" +-- add current time to statusline
" {{{ Folding :
set foldenable " Turn on folding
"set foldmarker={,} " Fold C style code (only use this as default if you use a high foldlevel)
"set foldmethod=marker " Fold on the marker
"set foldlevel=1000 " Don't autofold anything (but I can still fold manually)
set foldopen=block,hor,mark,percent,quickfix,tag " what movements open folds
set foldmethod=syntax " By default, use syntax to determine folds
set foldlevelstart=2000 " All folds open by default
" / Folding }}}
" / Graphical }}}
" {{{ Typing (Textual) :
" {{{ Notes :
augroup NOTES
au!
" @TODO : Get this working... :S
au BufRead,BufNewFile *notes set foldlevel=2
au BufRead,BufNewFile *notes set foldmethod=indent
au BufRead,BufNewFile *notes set foldtext=foldtext()
"au BufRead,BufNewFile *notes set listchars=tab:\ \
au BufRead,BufNewFile *notes set noexpandtab
au BufRead,BufNewFile *notes set shiftwidth=4
au BufRead,BufNewFile *notes set softtabstop=4
au BufRead,BufNewFile *notes set tabstop=4
au BufRead,BufNewFile *notes set syntax=notes
"au BufRead,BufNewFile *notes set guifont=Consolas:h12
au BufRead,BufNewFile *notes set spell spelllang=en_US,nl_NL
augroup END
" / Notes }}}
" {{{ Spelling :
" \sh ("spelling highlight") highlights (in red) all misspelt words in the
" current buffer, and also excluding the possessive forms of any valid words
" (E.G. "Lizzy's" won't be highlighted if "Lizzy" is in the dictionary); with
" mail and news messages it ignores headers and quoted text; for HTML it
" ignores tags and only checks words that will appear, and turns off other
" syntax highlighting to make the errors more apparent [function at end of file]:
nnoremap \sh :set invspell<CR>
nmap <F9> \sh
" / Spelling }}}
" {{{ Indenting :
" Tabs/Indent Levels
" :help filetype-indent-off
set autoindent " Do dumb autoindentation when no filetype is set
set tabstop=3 " Real tab characters are 3 spaces wide,
set shiftwidth=3 " and an indent level is 3 spaces wide.
set softtabstop=3 " <BS> over an autoindent deletes all `space`.
set noexpandtab " I rather like tabs at the beginning of every line "set expandtab " Use spaces, not tabs, for autoindent/tab key.
" / Indenting }}}
" {{{ Tags :
set tags=./../tags,./../TAGS ";../TAGS;./tags;./TAGS;tags;TAGS " Tags can be in almost anywhere ? :P
set showfulltag " Show more information while completing tags.
" / Tags }}}
" normally don't automatically format `text' as it is typed, IE only do this
" with comments, at 79 characters:
set formatoptions-=t
set textwidth=179
" Wrap text
set nowrap
set wrapmargin=-20
" {{{ Comments :
" Remove the default
set comments-=s1:/*,mb:*,ex:*/
" Insert my style of comments
set comments+=s:/**,mb:**,ex:**/
" Add " to be a comment as well
set comments+=b:\"
" {{{ NERDCommenter :
" Prevent NERD Commenter from complaining about unknown file types
let NERDShutUp=1
" / NERDCommenter }}}
" / Comments }}}
" {{{ Encoding / Multibyte :
if has('multi_byte') " If multibyte support is available and
if &enc !~? 'utf-\=8' " the current encoding is not Unicode,
if empty(&tenc) " default to
let &tenc = &enc " using the current encoding for terminal output
endif " unless another terminal encoding was already set
set enc=utf-8 " but use utf-8 for all data internally
endif
endif
" / Encoding / Multibyte }}}
" / Typing (Textual) }}}
" {{{ Miscelanneous :
" {{{ Moving Around & Editing :
set nostartofline " Avoid moving cursor to BOL when jumping around
set whichwrap=b,s,h,l,<,> " <BS> <Space> h l <Left> <Right> can change lines
set virtualedit=block " Let cursor move past the last char in <C-v> mode
set scrolloff=3 " Keep 3 context lines above and below the cursor
set backspace=2 " Allow backspacing over autoindent, EOL, and BOL
set showmatch " Briefly jump to a paren once it's balanced
set matchtime=2 " (for only .2 seconds). " how many tenths of a second to blink matching brackets for
"< (blink meaning that the cursor(and you visually) will go there , but when you continue typing there are no troubles , it just continues where you left)
" {{{ Searching and Patterns :
set noignorecase " Default to using case sensitive searches,
set smartcase " unless uppercase letters are used in the regex.
set nohlsearch " Do not highlight searches by default.
set incsearch " Incrementally search while typing a /regex
" / Searching and Patterns }}}
" / Moving around & Editing }}}
" {{{ GetLatest :
let g:GetLatestVimScripts_allowautoinstall=1
" / GetLatest }}}
syntax on
filetype on " enable filetype detection
filetype plugin on
"filetype plugin indent on
" {{{ Mouse , Keyboard , Terminal :
"set mouse=a " enable the use of a mouse inside a console
set mouse=nv " Allow mouse use in normal and visual mode.
set mousehide " hide the mouse cursor when typing
set ttymouse=xterm2 " Most terminals send modern xterm mouse reporting
" but this isn't always detected in GNU Screen.
set timeoutlen=1000 " Wait 2 seconds before timing out a mapping
set ttimeoutlen=50 " and only 100 ms before timing out on a keypress.
"set lazyredraw " Avoid redrawing the screen mid-command.
set ttyscroll=3 " Prefer redraw to scrolling for more than 3 lines " set scrolloff=3 has been done already
" / Mouse , Keyboard , Terminal }}}
" {{{ Titlebar :
set title " Turn on titlebar support
" Set the to- and from-status-line sequences to match the xterm titlebar
" manipulation begin/end sequences for any terminal where
" a) We don't know for a fact that these sequences would be wrong, and
" b) the sequences were not already set in terminfo.
" NOTE: This would be nice to fix in terminfo, instead...
if &term !~? '^\v(linux|cons|vt)' && empty(&t_ts) && empty(&t_fs)
exe "set t_ts=\<ESC>]2;"
exe "set t_fs=\<C-G>"
endif
let &titlestring = '%f'
" Titlebar string: hostname> ${PWD:s/^$HOME/~} || (view|vim) filename ([+]|)
"let &titlestring = hostname() . '> ' . '%{expand("%:p:~:h")}'
" \ . ' || %{&ft=~"^man"?"man":&ro?"view":"vim"} %f %m'
" When vim exits and the original title can't be restored, use this string:
if !empty($TITLE)
" We know the last title set by the shell. (My zsh config exports this.)
let &titleold = $TITLE
else
" Old title was probably something like: hostname> ${PWD:s/^$HOME/~}
"let &titleold = hostname() . '> ' . fnamemodify($PWD,':p:~:s?/$??')
let &titleold = fnamemodify($PWD , '$??')
endif
" / Titlebar }}}
" {{{ Reading , Writing :
set noautowrite " Never write a file unless I request it.
set noautowriteall " NEVER.
set noautoread " Don't automatically re-read changed files.
set modeline " Allow vim options to be embedded in files; " But I kind of like it , so I'll allow it. "set nomodeline" don't have files trying to override this .vimrc: (The first or last line in a file)
set modelines=5 " they must be within the first or last 5 lines.
set ffs=unix,dos,mac " Try recognizing dos, unix, and mac line endings.
" / Reading , Writing }}}
" {{{ Backups & Swap Files :
" Make sure that the directory where we want to put swap/backup files exists.
if ! len(glob("~/.vim/backups/"))
silent echomsg "Backup directory ~/.vim/backups doesn't exist!"
endif
set writebackup " Make a backup of the original file when writing
set backup " and don't delete it after a succesful write.
set backupskip= " There are no files that shouldn't be backed up.
set backupdir^=~/.vim/backups " Backups are written to ~/.vim/backups/ if possible.
set directory^=~/.vim/swap_files " Swap files are written to ~/.vim/swap_files if possible.
set updatetime=4000 " Write swap files after 4 seconds of inactivity.
set backupext=~ " Backup for "file" is "file~"
" / Backups & Swapfiles }}}
" / Miscelanneous }}}
" {{{ Autocommands :
" {{{ To let alias work the shell has to be started interactively , can be done by settting the `shellcmdflag`.
"set shellcmdflag=-ic
"set isk=@,48-57,_
"set isk=@,48-57
"set isk=@,48-57,$
"set isk+=$
se isk=48-57,192-255,~,_,@,$
" / To let alias work the shell has to be started interactively , can be done by settting the `shellcmdflag`. }}}
" {{{ Remembering :
" {{{ History
set history=100
"set viminfo='50,\"100,!
"let &viminfo = &viminfo . ",r" . expand("$VIMRUNTIME")
"let &viminfo = &viminfo . ",n" . expand("$VIM/_viminfo")
set history=5000
set viminfo='1024,<0,s100,f0,r/tmp,r/mnt
"" see :h last-position-jump
au BufReadPost * if line("'\"") > 0|if line("'\"") <= line("$")|exe("norm'\"")|else|exe "norm $"|endif|endif
" {{{ Jump to the last known cursor position for this file :
"au! BufReadPost *
" \ if line("'\"") > 0 && line("'\"") <= line("$") |
" \ exe "normal g`\"" |
" \ endif
" / Jump to the last known cursor position for this file }}}
" / History }}}
" {{{ Remember folds after quitting :
autocmd BufWinLeave *.* mkview
autocmd BufWinEnter *.* silent loadview
" / Remember folds after quitting }}}
" / Remembering }}}
" / Autocommands }}}
" {{{ Plugins / Addons :
" {{{ DoxyGen :
let g:load_doxygen_syntax=1
let g:doxygen_enhanced_colour=1
let load_doxygen_syntax=1
" / DoxyGen }}}
" {{{ PHP-Doc :
"""""""source ~/.vim/plugin/php-doc.vim
imap <C-o> :set paste<CR>:exe PhpDoc()<CR>:set nopaste<CR>i
let g:pdv_cfg_Author = "username <email>"
let g:pdv_cfg_Copyright = "periode1-periode2 copyright_holder"
"let g:pdv_cfg_License = "GPL version 3 and up {@link http://gnu.com/gpl.txt}"
let g:pdv_cfg_License = "license +eventueel een link, voorbeeld hierboven"
" / PHP-Doc }}}
" {{{ Align.vim :
"" Lining up code into columns using the nice Align plugin
"let g:loaded_alignmaps=1
"""""""call Align#AlignCtrl('=Wp2P2')
vnoremap <silent> <Leader>= <ESC>:AlignPush<CR>:AlignCtrl =Wlp2P2<CR>:'<,'>Align =<CR>:AlignPop<CR>:'<,'> ==<CR>
"vnoremap <silent> <Leader>i, <ESC>:AlignPush<CR>:AlignCtrl lp0P1<CR>:'<,'>Align ,<CR>:AlignPop<CR>
"vnoremap <silent> <Leader>i( <ESC>:AlignPush<CR>:AlignCtrl lp0P0<CR>:'<,'>Align (<CR>:AlignPop<CR>
"vnoremap <silent> <Leader>i@ <ESC>:AlignPush<CR>:AlignCtrl lp0P0<CR>:'<,'>Align @<CR>:AlignPop<CR>
" / Align.vim }}}
" Plugins / Addons }}}
" {{{ Languages :
" {{{ PHP :
augroup PHP
au!
" autocmd FileType php map <C-_> :cstag <C-R>=expand("<cword>")<CR><CR>
" autocmd FileType php map g<C-]> :cs find 3 <C-R>=expand("<cword>")<CR><CR>
" autocmd FileType php map g<C-\> :cs find 0 <C-R>=expand("<cword>")<CR><CR>
autocmd FileType php nmap <C-_>s :cs find s <C-R>=expand("<cword>")<CR><CR>
autocmd FileType php nmap <C-_>g :cs find g <C-R>=expand("<cword>")<CR><CR>
autocmd FileType php nmap <C-_>c :cs find c <C-R>=expand("<cword>")<CR><CR>
autocmd FileType php nmap <C-_>t :cs find t <C-R>=expand("<cword>")<CR><CR>
autocmd FileType php nmap <C-_>e :cs find e <C-R>=expand("<cword>")<CR><CR>
autocmd FileType php nmap <C-_>f :cs find f <C-R>=expand("<cfile>")<CR><CR>
autocmd FileType php nmap <C-_>i :cs find i ^<C-R>=expand("<cfile>")<CR>$<CR>
autocmd FileType php nmap <C-_>d :cs find d <C-R>=expand("<cword>")<CR><CR>
" Using 'CTRL-spacebar' then a search type makes the vim window
" split vertically, with search result displayed in
" the new window.
autocmd FileType php nmap <C-Space>s :vert scs find s <C-R>=expand("<cword>")<CR><CR>
autocmd FileType php nmap <C-Space>g :vert scs find g <C-R>=expand("<cword>")<CR><CR>
autocmd FileType php nmap <C-Space>c :vert scs find c <C-R>=expand("<cword>")<CR><CR>
autocmd FileType php nmap <C-Space>t :vert scs find t <C-R>=expand("<cword>")<CR><CR>
autocmd FileType php nmap <C-Space>e :vert scs find e <C-R>=expand("<cword>")<CR><CR>
autocmd FileType php nmap <C-Space>f :vert scs find f <C-R>=expand("<cfile>")<CR><CR>
autocmd FileType php nmap <C-Space>i :vert scs find i ^<C-R>=expand("<cfile>")<CR>$<CR>
autocmd FileType php nmap <C-Space>d :vert scs find d <C-R>=expand("<cword>")<CR><CR>
" Hitting CTRL-space *twice* before the search type does a horizontal
" split instead of a vertical one
autocmd FileType php nmap <C-Space><C-Space>s :scs find s <C-R>=expand("<cword>")<CR><CR>
autocmd FileType php nmap <C-Space><C-Space>g :scs find g <C-R>=expand("<cword>")<CR><CR>
autocmd FileType php nmap <C-Space><C-Space>c :scs find c <C-R>=expand("<cword>")<CR><CR>
autocmd FileType php nmap <C-Space><C-Space>t :scs find t <C-R>=expand("<cword>")<CR><CR>
autocmd FileType php nmap <C-Space><C-Space>e :scs find e <C-R>=expand("<cword>")<CR><CR>
autocmd FileType php nmap <C-Space><C-Space>f :scs find f <C-R>=expand("<cfile>")<CR><CR>
autocmd FileType php nmap <C-Space><C-Space>i :scs find i ^<C-R>=expand("<cfile>")<CR>$<CR>
autocmd FileType php nmap <C-Space><C-Space>d :scs find d <C-R>=expand("<cword>")<CR><CR>
" cstags... ?
autocmd FileType php set tagstack
" Make <C-;> :stjump
autocmd FileType php nnoremap g] :stjump<CR>
"autocmd BufNewFile,BufRead *.php nmap <Leader>v Iecho '<pre>'; var_dump(<ESC>A); echo '</pre>';<ESC>
autocmd BufNewFile,BufRead *.php nmap <Leader>v Ivar_dump( <ESC>A );<ESC>
autocmd BufNewFile,BufRead *.php nmap <Leader>pc iclass<CR>{<CR>public function __construct ()<CR>{<CR><CR>}<CR>}<CR>
autocmd BufNewFile,BufRead *.php nmap <Leader>pi :s/$\?\(\S\+\)/$this->\1 = $\1;/<CR>
autocmd FileType php set indentexpr=
autocmd FileType php set cindent
autocmd FileType php set cinoptions=>2s,e2s,n2s,f1s,0N,{1s,}0,^1s,:1s,=2s,l0,b1,g1s,c5,C1,(0,u0,U1,w1,W1s,m1,)30,*20
autocmd FileType php set cinwords-=for,if
autocmd FileType php set nosmartindent
autocmd FileType php set autoindent
autocmd FileType php set tabstop=3
autocmd FileType php set shiftwidth=3
autocmd FileType php set syntax=php.doxygen
autocmd FileType php set indentexpr= cindent noai nospell syntax=php.doxygen
"autocmd FileType php set comments=sO:*\ -,mO:*\ \ ,exO:*/,s1:/*,mb:*,ex:*/,bO:///,O://,s1:/**,mb:**,ex:**/
autocmd FileType php set comments=bs:/**,bm:**\ ,bex:**/,bO://,bO:#
" set "make" command when editing php files
" To use, simply issue “:make %” command inside of VIM to check the syntax of your php against the interpreter.
autocmd FileType php set makeprg=php\ -l\ %
autocmd FileType php set errorformat=%m\ in\ %f\ on\ line\ %l
" run file with PHP CLI (CTRL-M)
autocmd FileType php noremap <C-M> :make<CR>
"the % already is set in the makeprg "used to be :w!<CR>:!php %<CR>
autocmd FileType php noremap <C-F> :call OpenPhpFunction('<c-r><c-w>')<CR>
" With the following map, you can quickly fix this problem by typing \4 while the cursor is still on the same line,
" after the '4' (this assumes the default backslash <Leader> key):
autocmd FileType php nnoremap <Leader>p4 m`F4r$``:w<CR>
autocmd FileType php inoremap <Leader>p4 <Esc>m`F4r$``:w<CR>a
" set auto-highlighting of matching brackets for php only
autocmd FileType php DoMatchParen
autocmd FileType php hi MatchParen ctermbg=blue guibg=lightblue
" {{{ :he php-indent :
autocmd FileType php let g:PHP_autoformatcomment = 0 " Do not automatically format comment , I want to specify my own `formatting`.
autocmd FileType php let g:PHP_default_indenting = 0 " Don't do dany default indenting
autocmd FileType php let g:PHP_default_indenting = 1 " Let PHP-code be indented on shiftwidth by default
autocmd FileType php let g:PHP_removeCRwhenUnix = 1 " automatically remove '\r' characters when the 'fileformat' is set to Unix:
autocmd FileType php let g:PHP_BracesAtCodeLevel = 0 " indent braces at the same level as the code hat they contain
autocmd FileType php let g:PHP_vintage_case_default_indent = 1 " indent 'case:' and 'default:' statements in switch() blocks
" / :he php-indent }}}
" {{{ :he ft-php-syntax :
autocmd FileType php let php_sql_query = 1
autocmd FileType php let php_baselib = 1
autocmd FileType php let php_htmlInStrings = 1
autocmd FileType php let php_noShortTags = 1
autocmd FileType php let php_parent_error_close = 1
autocmd FileType php let php_parent_error_open = 1
autocmd FileType php let php_folding = 1
autocmd FileType php let php_sync_method = -1
" autocmd FileType php php_sync_method = -1 "to sync by search (default),
" autocmd FileType php php_sync_method > 0 "to sync at least x lines backwards,
" autocmd FileType php php_sync_method = 0 "to sync from start.
" / :he ft-php-syntax }}}
autocmd BufNewFile *.phtml 0r ~/.vim/skeletons/my.phtml
\ | silent %s/<FILE>/\=expand("%:t")/
\ | silent %s/<DATETIME>/\=strftime("%a\ %0Y-%0m-%0d,\ %0H:%0M.%0S\ %Z")/
\ | silent %s/<DATE>/\=strftime("%0Y-%0m-%0d")/
\ | silent! %s g
\ | w
"autocmd BufNewFile *.php 0r ~/.vim/skeletons/my.php
"\ | silent! %s g
"\ | w
autocmd BufNewFile *.inc.php 0r ~/.vim/skeletons/my.php
\ | silent! %s g
\ | w
autocmd BufNewFile *.class.php 0r ~/.vim/skeletons/my.class.php
\ | silent %s/<CLASS_NAME>/\="<CLASS_NAME".expand("%:t:r:r").">"/
\ | silent %s/<CLASS_NAME\(.\)\([^>]\+\)>/<CLASS_NAME\u\1\2>/
\ | silent! %s/<CLASS_NAME\([^_]\+\)_\(.\)\([^>]\+\)>/<CLASS_NAME\1\u\2\3>/eI
\ | silent! %s g
\ | silent %s/<CLASS_NAME\([^>]*\)>/\1/
\ | w
autocmd BufNewFile *.php
\ | silent %s/<FILE>/\=expand("%:t")/
\ | silent %s/<DATETIME>/\=strftime("%a\ %0Y-%0m-%0d,\ %0H:%0M.%0S\ %Z")/
\ | silent %s/<DATE>/\=strftime("%0Y-%0m-%0d")/
\ | silent! %s g
\ | w
" {{{ Set current directory for file being edited :
"au! BufEnter *[^{.php}|{.phtml}] exe "silent! lcd %:p:h"
"au! BufEnter *[^{.php}|{.phtml}] exe "silent! cd $PWD"
au! BufEnter *[{.php}|{.phtml}] exe "silent! cd $PWD"
autocmd VimEnter *.php exe "cd $PWD"
autocmd VimEnter *.phtml exe "cd $PWD"
" / Set current directory for file being edited }}}
autocmd BufWritePre,FileWritePre *.php ks | call LastModidified() | 's
autocmd BufWritePre,FileWritePre *.phtml ks | call LastModidified() | 's
autocmd InsertLeave *.php update
autocmd InsertLeave *.phtml update
augroup END
" {{{ Project :
let g:project_flags="bcgiLmsStTv"
"let a:filename="../vim.project"
nmap <silent> <Leader>p :Project<CR>
" / Project }}}
" / PHP }}}
" {{{ JS / JavaScript :
autocmd BufNewFile *.js 0r ~/.vim/skeletons/my.js
\ | silent %s/<FILE>/\=expand("%:t")/
\ | silent %s/<DATETIME>/\=strftime("%a\ %0Y-%0m-%0d,\ %0H:%0M.%0S\ %Z")/
\ | silent %s/<DATE>/\=strftime("%0Y-%0m-%0d")/
\ | silent! %s g
\ | w
autocmd BufWritePre,FileWritePre *.js ks | call LastModidified() | 's
autocmd BufNewFile,BufRead *.php nmap <Leader>jc Iconsole.log( <ESC>A );<ESC>
" / JS / JavaScript }}}
" {{{ CSS
augroup CSS
au!
autocmd InsertLeave *.css update
autocmd BufWritePre,FileWritePre *.css ks | call LastModidified() | 's
augroup END
" / CSS }}}
" {{{ (La)TeX
augroup TEX
let g:Tex_Folding=0 "I don't like folding.
augroup END
" / (La)TeX }}}
" / Languages }}}
" {{{ Function definitions :
" autocmd FileType php map <Leader>q execute 'execute WF_Com()'
"
"function! WF_Com ()
" let l:string = getline(".")
" if matchstr('/^#/' , l:string)
" execute 's/^#//'
" else
" execute 's/^/#/'
" endif
" execute 'nohlsearch'
"endfunction
function! LastModidified()
if line("$") > 20
let l = 20
else
let l = line("$")
endif
execute "1," . l . "g/Last modified: /s/Last modified: .*/Last modified: " .
\ strftime("%a\ %0Y-%0m-%0d,\ %0H:%0M.%0S\ %Z")
endfunction
function! EatChar(pat)
let c = nr2char(getchar(0))
return (c =~ a:pat) ? '' : c
endfunction
function! s:ToggleTooLongHL()
if exists('*matchadd')
if ! exists("w:TooLongMatchNr")
let last = (&tw <= 0 ? 80 : &tw)
let w:TooLongMatchNr = matchadd('ErrorMsg', '.\%>' . (last+1) . 'v', 0)
echo " Long Line Highlight"
else
call matchdelete(w:TooLongMatchNr)
unlet w:TooLongMatchNr
echo "No Long Line Highlight"
endif
endif
endfunction
"function! OpenPhpFunction (keyword)
" let proc_keyword = substitute(a:keyword , '_', '-', 'g')
" execute 'vsplit'
" execute 'enew'
" execute 'set buftype=nofile'
" "execute 'silent r!lynx -dump -nolist http://php.net/manual/en/print/function.'.proc_keyword.'.php'
" execute 'r !cat /home/user/Desktop/download/programs/helper_programs/php/vim-php-manual/'.proc_keyword.'.txt'
" execute 'set filetype=help'
" execute 'norm gg'
" execute 'call search ("' . a:keyword .'")'
" execute 'norm dgg'
" execute 'call search("Parameters")'
" execute 'norm dGgg'
"endfunction
" / Function definitions }}}
" many thanks to : Matthew Wozniski (mjw@drexel.edu) godlygeek @ #vim
" ( http://github.com/godlygeek/vim-files/blob/master/.vimrc )
map ,w :update<CR>
map ,q :qa<CR>
" swap two words(before a <space-char><no-space-char><space-char> -pattern:
map <Leader>sw vlEdww[plvlEbbedBbbp
" vim: set foldmethod=marker foldmarker={{{,}}} foldlevel=2000 nospell:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment