美文网首页工具控
vim vundle clang-format 配置

vim vundle clang-format 配置

作者: 国服最坑开发 | 来源:发表于2019-12-24 11:01 被阅读0次

    1 下载Vundle库

    git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim

    .vimrc

    set nocompatible              " be iMproved, required
    filetype off                  " required
    
    " set the runtime path to include Vundle and initialize
    set rtp+=~/.vim/bundle/Vundle.vim
    call vundle#begin()
    " alternatively, pass a path where Vundle should install plugins
    "call vundle#begin('~/some/path/here')
    
    " let Vundle manage Vundle, required
    Plugin 'VundleVim/Vundle.vim'
    
    " The following are examples of different formats supported.
    " Keep Plugin commands between vundle#begin/end.
    " plugin on GitHub repo
    Plugin 'tpope/vim-fugitive'
    " plugin from http://vim-scripts.org/vim/scripts.html
    " Plugin 'L9'
    " Git plugin not hosted on GitHub
    Plugin 'git://git.wincent.com/command-t.git'
    " git repos on your local machine (i.e. when working on your own plugin)
    Plugin 'file:///home/gmarik/path/to/plugin'
    " The sparkup vim script is in a subdirectory of this repo called vim.
    " Pass the path to set the runtimepath properly.
    Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}
    " Install L9 and avoid a Naming conflict if you've already installed a
    " different version somewhere else.
    " Plugin 'ascenator/L9', {'name': 'newL9'}
    
    " All of your Plugins must be added before the following line
    call vundle#end()            " required
    filetype plugin indent on    " required
    " To ignore plugin indent changes, instead use:
    "filetype plugin on
    "
    " Brief help
    " :PluginList       - lists configured plugins
    " :PluginInstall    - installs plugins; append `!` to update or just :PluginUpdate
    " :PluginSearch foo - searches for foo; append `!` to refresh local cache
    " :PluginClean      - confirms removal of unused plugins; append `!` to auto-approve removal
    "
    " see :h vundle for more details or wiki for FAQ
    " Put your non-Plugin stuff after this line
    

    启动

    :PluginInstall 完成插件安装

    配置 clang-format插件

    参考:https://www.cnblogs.com/lepeCoder/p/8032178.html

    • .vimrc 添加

    Plugin 'rhysd/vim-clang-format'

    • 安装

    :PluginInstall

    • .vimrc配置
    set ts=4
    let g:clang_format#auto_format_on_insert_leave=1
    

    手动安装 clang-format

    apt install clang-format

    • 配置 ~/.clang-format
    #基于那个配置文件
    BasedOnStyle: LLVM
    #指针的*的挨着哪边
    PointerAlignment: Right
    #缩进宽度
    IndentWidth: 4
    # 连续的空行保留几行
    MaxEmptyLinesToKeep: 1
    # 在 @property 后面添加空格, \@property (readonly) 而不是 \@property(readonly).
    ObjCSpaceAfterProperty: true
    # OC block后面的缩进
    ObjCBlockIndentWidth: 4
    # 是否允许短方法单行
    AllowShortFunctionsOnASingleLine: true
    # 是否允许短if单行 If true, if (a) return; 可以放到同一行
    AllowShortIfStatementsOnASingleLine: true
    #注释对齐
    AlignTrailingComments: true
    # 换行的时候对齐操作符
    #AlignOperands: true
    # 中括号两边空格 [] 
    SpacesInSquareBrackets: true
    # 小括号两边添加空格
    SpacesInParentheses : false
    #多行声明语句按照=对齐
    AlignConsecutiveDeclarations: true
    #连续的赋值语句以 = 为中心对齐
    AlignConsecutiveAssignments: true
    #等号两边的空格
    SpaceBeforeAssignmentOperators: true
    # 容器类的空格 例如 OC的字典
    SpacesInContainerLiterals: true
    #缩进
    IndentWrappedFunctionNames: true
    #在block从空行开始
    KeepEmptyLinesAtTheStartOfBlocks: true
    #在构造函数初始化时按逗号断行,并以冒号对齐
    BreakConstructorInitializersBeforeComma: true
    #函数参数换行
    AllowAllParametersOfDeclarationOnNextLine: true
    #括号后添加空格
    SpaceAfterCStyleCast: true
    #tab键盘的宽度
    TabWidth: 4
    UseTab: Never
    

    相关文章

      网友评论

        本文标题:vim vundle clang-format 配置

        本文链接:https://www.haomeiwen.com/subject/zimxoctx.html