Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
133 lines (119 sloc) 3.55 KB
function! IndentPHP()
let old_ft = &l:ft
let old_et = &l:et
set ft=php et ts=4 sw=4
:'<,'>s/^\(\t\| \)*//g
:'<,'>s/\(class .*\) *{/\1 { /ge
:'<,'>s/\(function .*\) *{/\1 { /ge
:'<,'>s/function\n\s*/function /g
:'<,'>s/ }/ }/ge
normal `<O<?php
normal gv=
normal `<-1dd
:'<,'>s/^/ /
:'<,'>s/ *$//e
:'<,'>s/}\n\n\n\( *}\)/} \1/e
:'<,'>s/\\_\([A-Z]\)/_\1/ge
normal `>A 
let &l:ft = old_ft
let &l:et = old_et
endfunction
noremap <Leader>ip :<C-U>call IndentPHP()<CR>
function! IndentTable()
:'<,'>s/\n/ /g
:'<,'>s/\s*\\|\\|\s\{1,5}\\|\\|\s*/ /g
:'<,'>s/^\s*//g
:'<,'>s/\s*\\|\\|\s*/\t/g
endfunction
noremap <Leader>it :<C-U>call IndentTable()<CR>
function! IndentSql()
:'{,'}s/\C^\s*SELECT\(\n\|\s*\)/SELECT /
:'{,'}s/,\s*\([a-z]\.[a-z]\+ AS [a-z]__[a-z]\+\)/, \1/g
:'{,'}s/\C\(FROM\|WHERE\|ORDER BY\|GROUP BY\|HAVING\|LIMIT\|OFFSET\)\(\s*\|\n\)/ \1 /g
:'{,'}s/\C\(\n\|\s\)*\(\(LEFT\|RIGHT\|INNER\|OUTER\) JOIN\)\s*/ \2 /g
:'{,'}s/\C\(\n\|\s)*\(ON \)\s*/ \2/g
:FixWhitespace
endfunction
noremap <Leader>is :<C-U>call IndentSql()<CR>
function! IndentQuery()
:'<,'>s/\n/ /g
:'<,'>s/ ->/ ->/g
:'<,'>s/; /; /g
endfunction
noremap <Leader>iq :<C-U>call IndentQuery()<CR>
function! FixCautions()
/\*\*[A-Z]\+\*\*
:g/\*\*[A-Z]\+\*\*/.s/^\(.*\)\*\*\([A-Z]\+\)\*\* \(.*\)$/.. \L\2\E:: \1\3/
endfunction
noremap <Leader>fc :call FixCautions()<CR>
function! FixRoles()
:%s/``Doctrine``/:php:class:`Doctrine`/g
:%s/``Doctrine_Manager``/:php:class:`Doctrine_Manager`/g
:%s/``Doctrine_Connection``/:php:class:`Doctrine_Connection`/g
:%s/``Doctrine_Query``/:php:class:`Doctrine_Query`/g
:%s/``Doctrine_Collection``/:php:class:`Doctrine_Collection`/g
:%s/``Doctrine_Record``/:php:class:`Doctrine_Record`/g
:%s/``Doctrine_Table``/:php:class:`Doctrine_Table`/g
:%s/``Doctrine_Core::autoload``/:php:meth:`Doctrine_Core::autoload`/g
:%s/``Doctrine_Core::getTable``/:php:meth:`Doctrine_Core::getTable`/g
:%s/``Doctrine_Core::\([A-Z_]\+\)``/:php:const:`Doctrine_Core::\1`/g
:%s/``Doctrine_Manager::connection``/:php:meth:`Doctrine_Manger::connection`/g
:%s/``Doctrine_Record::hasMany``/:php:meth:`Doctrine_Record::hasMany`/g
:%s/``Doctrine_Record::hasOne``/:php:meth:`Doctrine_Record::hasOne`/g
:%s/``\([^`]*.php\)``/:file:`\1`/g
:%s/``\([^`]*\)()``/:php:meth:`\1`/g
endfunction
noremap <Leader>fr :call FixRoles()<CR>
function! FixExamples()
:%s/^\/\/ ... //
:%s/^\n \(\/\/ [a-z]*.php\)\n\n/ \1 /
:%s/:code:`\(.*\)`\\ /$\1$/
endfunction
noremap <Leader>fe :call FixExamples()<CR>
function! FixTitles()
:g/^++ /normal ^3dlVypVr=VykP
:g/^+++ /normal ^4dlVypVr-VykP
:g/^++++ /normal ^5dlVypVr^VykP
:g/^+++++ /normal ^6dlVypVr"VykP
:g/^\*\*[^\*]*:\*\*$/normal ^2dl$h2dl^i 
:%s/\.\.\.\n===\n\n//e
endfunction
noremap <Leader>ft :call FixTitles()<CR>
function! FixTitlesJP()
:g/^++ /normal ^3dl^yv$o ppVr=VykP
:g/^+++ /normal ^4dl^yv$o ppVr-VykP
:g/^++++ /normal ^5dl^yv$o ppVr^VykP
:g/^+++++ /normal ^6dl^yv$o ppVr"VykP
:%s/\.\.\.\n===\n\n//e
endfunction
function! FixLinks()
:%s/\[\(http:\/\/\_.\{-}\) \(\_.\{-}\)\]/`\2 <\1>`_/g
:%s/\[doc \([A-Za-z-]\+\) :name\]/:doc:`\1`/g
:%s/\[doc \([A-Za-z-]\+\) \([A-za-z ]\{-}\)\]/:doc:`\2 <\1>`/g
endfunction
noremap <Leader>fl :call FixLinks()<CR>
function! FixMisc()
:%s/\\_/_/g
:%s/\\\*/*/g
:%s/^- /* /g
:%s/:code:`\(.*\)`\\ /$\1$/g
endfunction
noremap <Leader>fm :call FixMisc()<CR>
Something went wrong with that request. Please try again.