0

I use Vim to edit Ruby code, and the one issue that I keep having trouble with is the comment indenting. It seems that Vim really wants all # comment marks that begin a line to indent all the way to the left. If I type a # at the beginning of a line, no matter what my indent currently is, it always drops the whole line to zero indent, no matter whether there is already code on the line or not. None of the normal indent commands work from here either. The only way to move the line is to manually insert spaces.

What I'd like it to do is to just leave the indent where it is when I add a comment mark to a line. I've spent what seems like forever messing with various comment settings and checking the indent/ruby.vim file, and I still can't find anything that has any effect on this behavior. Can anybody point me at something that works?

  • 1
    By default this isn't how the Ruby indentation should behave. I suspect there is a plugin or something else you once stuck in your vimrc that is causing this. You can try following the steps in How do I debug my vimrc file?. If that doesn't help post your Vim version and full vimrc that you're using. – Martin Tournoij Nov 16 '16 at 20:57
2

Thanks to the comment's help, I was able to muck around with my .vimrc some more and isolate the issue to the commented-out line:

filetype indent on

Not sure how I missed that before, but it works now, so thanks!

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.