V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
xinali
V2EX  ›  Vim

NERD Commenter 配置问题

  •  
  •   xinali · 2016-08-09 21:56:47 +08:00 · 2005 次点击
    这是一个创建于 2823 天前的主题,其中的信息可能已经有所发展或是发生改变。

    NERD Commenter 的具体配置如下

    " NERD Commenter config
    " Add spaces after comment delimiters by default
    let g:NERDSpaceDelims = 1
    
    " Use compact syntax for prettified multi-line comments
    let g:NERDCompactSexyComs = 1
    
    " Align line-wise comment delimiters flush left instead of following code indentation
    let g:NERDDefaultAlign = 'left'
    
    " Set a language to use its alternate delimiters by default
    let g:NERDAltDelims_java = 1
    
    " Add your own custom formats or override the defaults
    let g:NERDCustomDelimiters = { 'c': { 'left': '/*','right': '*/' } }
    
    " Allow commenting and inverting empty lines (useful when commenting a region)
    let g:NERDCommentEmptyLines = 1
    
    " Enable trimming of trailing whitespace when uncommenting
    let g:NERDTrimTrailingWhitespace = 1
    

    其他的配置都是默认的,但是在注释 python 的时候,会在注释符后加两个空格,别的文件的注释目前没有发现问题,这是怎么回事呢?

    第 1 条附言  ·  2016-08-09 23:09:54 +08:00
    问题解决(感谢 @xucuncicero):
    通过<leader>ca 切换一下注释符即可!
    3 条回复    2016-08-21 19:44:24 +08:00
    xucuncicero
        1
    xucuncicero  
       2016-08-09 22:16:04 +08:00   ❤️ 1
    let g:NERDSpaceDelims = 1 这个设置为 0 ;

    或者编辑 python 时,按一下<leader>ca ,注意看看变化。
    xinali
        2
    xinali  
    OP
       2016-08-21 17:42:22 +08:00
    @xucuncicero 这个能不能配置默认的注释符呢?
    xucuncicero
        3
    xucuncicero  
       2016-08-21 19:44:24 +08:00
    @xinali

    :h 'NERDCustomDelimiters'
    :h NERDComDefaultDelims

    设置不能满足要求的话,自己修改 plugin/NERD_commenter.vim 里面的
    ```
    \ 'python': { 'left': '# ', 'leftAlt': '#' },
    ```
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2249 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 08:53 · PVG 16:53 · LAX 01:53 · JFK 04:53
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.