mirror of
https://github.com/ViViDboarder/vim-abuse-the-force.git
synced 2024-11-22 03:36:37 +00:00
fef0b0a6da
Make ForceDeploy and other commands override with bang
33 lines
662 B
VimL
33 lines
662 B
VimL
function! FormatApex()
|
|
" Mark current location
|
|
normal mz
|
|
|
|
" Delete extra lines
|
|
:%s/\s\+$//e
|
|
:%s/\n\{3,}/\r\r/e
|
|
|
|
" Delete blank lines before } after ; or }
|
|
:%s/;\s*\n\s*\n\s*}/;\r}/ge
|
|
:%s/}\s*\n\s*\n\s*}/}\r}/ge
|
|
|
|
" Delete blank lines before catch and else
|
|
:%s/}\s*\n\s*\n\s*catch/}\rcatch/ge
|
|
:%s/}\s*\n\s*\n\s*else/}\relse/ge
|
|
|
|
" Put space after if/for/while/catch
|
|
:%s/if(/if (/ge
|
|
:%s/for(/for (/ge
|
|
:%s/while(/while (/ge
|
|
:%s/catch(/catch (/ge
|
|
|
|
" Put space between ){
|
|
:%s/){/) {/ge
|
|
|
|
" Fix indentations
|
|
normal gg=G
|
|
|
|
" return to starting point
|
|
normal `z
|
|
endfunction
|
|
command! FormatApex call FormatApex()
|
|
command! FixApex call FormatApex() |