Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm getting some annoying behavior in Vim. If I'm on a line that's indented (4-spaces), and I hit o to open a new line, it puts me in insert mode with my cursor properly on the indented lines, but if I type a #, it jumps back to the leftmost column.

I downloaded someone else's setup and have made a few mods, but I can't seem to figure out the cause.

Here's my vimrc:

share|improve this question
up vote 1 down vote accepted

This behavior depends on the value of formatoptions. The value returned by :set fo should contain the letters r and o for Vim to do what you expect (see :h fo-table).

Do :verbose set fo to see where it was last defined.

Oh! And using someone else's config is a very bad idea.

share|improve this answer
Well the guy who wrote the vimrc set it up as a github repo and actually wrote a blog about it. – Ben Mordecai Feb 8 '13 at 16:05
Since my vimrc does not have format options set anywhere, I suppose that means that it's default? :verbose set fo tells me formatoptions=tcq Last set from ~/.vimrc but I don't have anything referencing formatoptions in my vimrc – Ben Mordecai Feb 8 '13 at 16:12
Yes that's vim's awkward and unhelpful way to say that it's the default value. Just set it explicitely to whatever you need. – romainl Feb 8 '13 at 16:56
Great, that worked. – Ben Mordecai Feb 8 '13 at 18:15

There was a post about this on stackoverflow. But this only works if you also "set cindent"

:set cindent
:set cinkeys-=0#
share|improve this answer
That does not work. – Ben Mordecai Feb 8 '13 at 5:15
Plus I'm in Python not C – Ben Mordecai Feb 8 '13 at 5:18
just making sure, lines 199 and 200 are your comments right? they don't work? Maybe i'll copy this vimrc and play around with it and see what I can do. when I did the above it worked for me, I apologize. – u8sand Feb 8 '13 at 14:08
Line 199 was a comment describing 200, I initially thought that 200 was the cause of the problem so I commented it out, but it did not help. Thanks for your help by the way. – Ben Mordecai Feb 8 '13 at 16:01
@BenMordecai the cinkeys does work but you ALSO need to "set cindent" I know you are not coding in C, but it works. – u8sand Feb 9 '13 at 16:29

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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