2015-04-17 77 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都是專門爲這個項目設計的。

相關問題