1

I am trying to use EnhancedCommentify plugin for vim and mostly using C. However I can't figure out the issue but when I comment/uncomment it uses (* ---- *) instead of /* ----- */. I tried to change the plugin itself, it didn't change anything. I also verified wit :set filetype? that vim recognizes the C code, and it does. I even looked for the languages that use (* *) for comment and simply removed the lines from the plugin : issue is still there !

It works fine for fortran, python and .vimrc however...

I am kinda puzzled at this, anyone has any idea ?

Also, the plugin did output an error when first using it :

Erreur détectée en traitant /home/jacques/.vim/plugin/EnhancedCommentify-2.3/ftplugin/php_enhcomm.vim :
ligne    6 :
E117: Fonction inconnue : EnhCommentifyFallback4Embedded

I opened the file and commented the line as i seemed to me it's only relevant for php, but maybe I am wrong...

On another note, I am also trying to remap the smart comment but it seems that I fail, here is the vimrc for now

vmap <unique> <C-c> <Plug>VisualComment
nmap <unique> <C-c> <Plug>Comment
imap <unique> <C-c> <ESC><Plug>Comment
vmap <unique> <F3> <Plug>VisualDeComment
nmap <unique> <F3> <Plug>DeComment
imap <unique> <F3> <ESC><Plug>DeComment

and i tried with "Guess" instead of "Comment" but it didn't seem to work. I remember doing this a long time ago but can't find my .vimrc from back then...

vmap VisualComment nmap Comment imap Comment vmap VisualDeComment nmap DeComment imap DeComment

0

I cannot answer directly your answer, cannot add a comment, but I'll still answer.

It seems like EnhancedCommentify have not beed updated for 6 years now. I suggest you try another plugin. I personnally use NerdCommenter and love it. You can find other such plugins on Vim Awesome.

Edit

Actually NerdCommenter was my very first comment plugin but I rapidly switched to Commentary, the gc mappings sticks very fine in muscle memory. Can't tell why I messed-up.

@Jacques, Commentary has the :Commentary command, so for insert-mode mapping, use

inoremap <C-c> <C-o>:Commentary<cr>

Now, for "unsupported" file formats, from :h commentary we can tell that it

Relies on 'commentstring' to be correctly set, or uses b:commentary_format if it is set.

So you can set the commentstring option for any filetype and it will work. See :h 'commentstring'. For example to add for python :

autocmd! BufNewFile,BufRead *.py setlocal commentstring=#\ %s

Note

  1. The python 'commentstring' is already set in default ftplugin/python.vim. It is just an example.
  2. This "answer" is off-topic regarding your initial question.
  • 2
    tpope’s commentary is also good. – D. Ben Knoble Jul 8 at 20:36
  • ok i'll try those, thanks for your help ! – jacques Jul 8 at 21:13
  • could you help me configure tpope's commentary ? I am kinda lost trying to fine tune it, to change the gc / gcc trigger to Ctrl-C and allow it to work on insert mode ! – Jacques Jul 9 at 9:11
  • well I kinda prefered enhancedcommentify coimpared to those two. It allows for insert mode commentary too, and also supports many more files (which i couldn't find how to add for tpope). I guess i'll try and make it work again... – Jacques Jul 11 at 8:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.