1

Ex, My C source code like this:

static float             getYuvMemoryRatio( int  format       )  {  
}

Is there some command to format my code as below:

static float getYuvMemoryRatio( int format ){
}
harris
  • 1,473
  • 1
  • 17
  • 26

1 Answers1

0

The fllowing is my config and verified by myself on c source code 1.Install Autoformat and astyle 2.add the following snip in your vimrc:

 398     " autoformat{
 399     noremap <F2> :Autoformat<CR><CR>
 400     "autocmd FileType * let "g:formatprg_".&filetype = "astyle"
 401     "autocmd FileType * let "g:formatprg_args_".&filetype = "--mode=cs --style=ansi -pcUHs4"
 402     "echo &filetype tell you the suffix of formatprg_
 403     let g:formatprg_c = "astyle"
 404     let g:formatprg_args_c = "--mode=cs --style=ansi -fDpcUs4"
 405     "let g:formatprg_args_cs = "--mode=cs --style=ansi -TU4pb"                                                                                                      
 406     " }

Everything works perfect for my code now. You can type "man astyle" and get to know the different option meaning

harris
  • 1,473
  • 1
  • 17
  • 26