2015-04-17 72 views
1

对于我的编码风格,我有一个很好的cindent配置,但是如果我将所有文件恢复到vim,我的文件的许可证头部会被重新格式化不正确。使用vim/cindent在C++文件中配置注释许可证头的缩进

许可证头:

/* ========================================================================= 

    Program: Visualization Toolkit 
    Module: vtkPeriodicArray.txx 

    Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 
    All rights reserved. 
    See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 

    This software is distributed WITHOUT ANY WARRANTY; without even 
    the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
    PURPOSE. See the above copyright notice for more information. 

========================================================================= */ 

我的.vimrc(相关部分):

:set tabstop=2 "Number of spaces a TAB in the text stands for 
:set shiftwidth=2 "Number of spaces used for each step of (auto)indent 
:set expandtab 
:set cindent 
:set cinoptions={1s,t0,f0s,g0,i0,(0 

希望的结果:在许可证头缩进没有变化

看结果:

/* ========================================================================= 

Program: Visualization Toolkit 
Module: vtkPeriodicArray.txx 

Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 
All rights reserved. 
See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 

This software is distributed WITHOUT ANY WARRANTY; without even 
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
PURPOSE. See the above copyright notice for more information. 

========================================================================= */ 

回答

0

我找到了解决办法。我只是在我的.vimrc映射以下命令:

map <F12> gg=G\|:3,12>\|:10,12> <Enter> <Enter> 

它F12键映射:

  • 重新缩进所有文件
  • 缩进线3至12一个缩进
  • 缩进线10到12的一个缩进

所以它是非常具体的我的头,并不会在另一个项目中工作。 我的所有vimrc都是专门为这个项目设计的。

相关问题