glts / vim-textobj-comment

Vim text objects for comments
http://www.vim.org/scripts/script.php?script_id=4570
130 stars 8 forks source link

Doesn't work from 'vim' filetype #5

Closed ssreekanth closed 8 years ago

ssreekanth commented 8 years ago

For example, in .vimrc, I have the following comment, and it is not treated as a comment text object.

" toggle invisible characters

filetype is detected correctly, however, comments seems to be wrong.

:set filetype? comments? commentstring?
  filetype=vim
  comments=s1:/*,mb:*,ex:*/,://,b:#,:%,:XCOMM,n:>,fb:-
  commentstring=/*%s*/
glts commented 8 years ago

Try to diagnose with :verbose set filetype? comments? commentstring?. On my OS X machine this outputs the following and textobj-comment works fine.

  filetype=vim
        Last set from /Applications/MacVim.app/Contents/Resources/vim/runtime/filetype.vim
  comments=sO:" -,mO:"  ,eO:"",:"
        Last set from /Applications/MacVim.app/Contents/Resources/vim/runtime/ftplugin/vim.vim
  commentstring="%s
        Last set from /Applications/MacVim.app/Contents/Resources/vim/runtime/ftplugin/vim.vim

I'd investigate why 'comments' and 'commentstring' are not set or reset in your setup. In any case this is not an issue in textobj-comment.

ssreekanth commented 8 years ago

My bad. I should have read the documentation before creating this issue.

filetype plugin indent on

was missing in my .vimrc

Thanks @glts for pointing me in the right direction..