簡體   English   中英

使用vim / cindent在C ++文件中配置注釋的許可標頭的縮進

[英]Configuring indentation of commented license header in C++ file with vim/cindent

我的編碼樣式具有良好的cindent配置,但是如果我重新插入vim中的所有文件,則文件的許可證標頭會重新正確地插入。

許可證標題:

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

  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.

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

我找到了解決方法。 我只是在.vimrc中映射以下命令:

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

它將F12鍵映射到:

  • 重新縮進所有文件
  • 縮進一個縮進的第3至12行
  • 縮進一個縮進的第10到12行

因此,它非常特定於我的標頭,無法在其他項目中使用。 無論如何,我所有的vimrc都是特定於該項目的。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM