Why, when I use the tComment VIM plugin in the .ini file, does it add / remove half columns instead of hashes as comments?

I am using gVIM and the tComment plugin while editing a development.ini file in a Pylons / Python project. The development.ini file by default has lines commented out using the hash # character , which is the standard method for commenting lines in Python. However, when I try to uncomment the lines using the tComment key combination in gVIM, I don't see the # go away. Instead, I see that the semicolon is added to the beginning of the line.

How to fix tComment's behavior so that it adds or removes #s instead of adding or removing semicolons in Pylons.ini files?

+3
source share
1 answer

In the file tcomment.vimin your startup directory you should find the following list:

call tcomment#DefineType('aap',              '# %s'             )
call tcomment#DefineType('ada',              '-- %s'            )
call tcomment#DefineType('apache',           '# %s'             )

Here you will find this line:

call tcomment#DefineType('dosini',           '; %s'             )

Assuming you don't need to comment on Windows.ini files too often, you can simply change it to this:

call tcomment#DefineType('dosini',           '# %s'             )

Update:

This is a little better since you don't need to edit anything except your vimrc. Since your vimrc is usually loaded first, any built-in file types that we are trying to determine get overridden by the above file, so let's do it yourself:

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

.ini , pythonini, tcomment.

vimrc , , tcomment, :

if exists('loaded_tcomment')
    au BufRead,BufNewFile, *.ini   set filetype=pythonini
    call tcomment#DefineType('pythonini',           '# %s'             )
endif
+10

Source: https://habr.com/ru/post/1771016/


All Articles