为什么我在.ini文件中使用tComment VIM插件时,它会添加/删除分号而不是散列作为注释?

3 python vim ini pylons comments

我在Pylons/Python项目中编辑development.ini文件时使用的是gVIM和tComment插件.默认的development.ini文件使用hash #符号注释掉了行符号,这是在Python中注释掉行的标准方法.但是,当我尝试在gVIM中使用tComment键盘快捷方式取消注释行时,我看不到#消失.相反,我看到分号被添加到行的开头.

如何更正tComment的行为,以便它添加或删除#s而不是添加或删除Pylons .ini文件中的分号?

All*_*tor 10

tcomment.vimautoload目录中的文件中,您应该找到如下列表:

call tcomment#DefineType('aap',              '# %s'             )
call tcomment#DefineType('ada',              '-- %s'            )
call tcomment#DefineType('apache',           '# %s'             )
Run Code Online (Sandbox Code Playgroud)

在那里你会找到这一行:

call tcomment#DefineType('dosini',           '; %s'             )
Run Code Online (Sandbox Code Playgroud)

假设你不需要发表评论窗口.ini文件过于频繁,你可以改成这样:

call tcomment#DefineType('dosini',           '# %s'             )
Run Code Online (Sandbox Code Playgroud)

更新:

这是一个稍微好一点的选项,因为除了你的vimrc之外你不需要编辑任何东西.由于你的vimrc通常首先加载,我们尝试定义的任何内置文件类型都由上面的文件重新定义,所以让我们自己创建:

au BufRead,BufNewFile, *.ini   set filetype=pythonini
call tcomment#DefineType('pythonini',           '# %s'             )
Run Code Online (Sandbox Code Playgroud)

我们首先将.ini文件设置为我们自己的文件类型pythonini,然后为它添加我们自己的tcomment定义.

为了保持你的vimrc漂亮和便携,你可能想要在尝试调用它之前检查我们是否有tcomment:

if exists('loaded_tcomment')
    au BufRead,BufNewFile, *.ini   set filetype=pythonini
    call tcomment#DefineType('pythonini',           '# %s'             )
endif
Run Code Online (Sandbox Code Playgroud)