【问题标题】:Is there some mean to delete or fulfill whitespace in Code?是否有一些方法可以删除或填充代码中的空格?
【发布时间】:2013-07-18 09:55:56
【问题描述】:

例如,我的 C 源代码如下:

static float             getYuvMemoryRatio( int  format       )  {  
}

是否有一些命令可以将我的代码格式化如下:

static float getYuvMemoryRatio( int format ){
}

【问题讨论】:

  • 您可以随时将其发送到外部命令,例如astyle、bcpp 或缩进。最近我开始使用 clang-format,它也不错,但仍在大量开发中。
  • 这里的“Ex”是指“例如”吗?
  • @innaM,是的,例如,不适合?
  • @mcalex,自动格式化无法去除多余的空格。

标签: vim vim-plugin


【解决方案1】:

以下是我的配置,并由我自己在 c 源代码上验证 1.安装Autoformat和astyle 2.在你的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     " }

现在一切都非常适合我的代码。您可以输入“man astyle”并了解不同的选项含义

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-12-21
    • 1970-01-01
    • 1970-01-01
    • 2016-05-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多