0

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: http://pastebin.com/9mGWr8Qf

2 Answers 2

1

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.

4
  • Well the guy who wrote the vimrc set it up as a github repo and actually wrote a blog about it. sontek.net/blog/detail/turning-vim-into-a-modern-python-ide Feb 8, 2013 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 Feb 8, 2013 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, 2013 at 16:56
  • Great, that worked. Feb 8, 2013 at 18:15
0

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

https://stackoverflow.com/questions/12469463/vim-c-back-indent-with

:set cindent
:set cinkeys-=0#
5
  • That does not work. Feb 8, 2013 at 5:15
  • Plus I'm in Python not C Feb 8, 2013 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, 2013 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. Feb 8, 2013 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, 2013 at 16:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .