# Vim autoindenting broken?

**URL:** <https://www.ruby-forum.com/t/vim-autoindenting-broken/81791>\
**Category:** Ruby\
**Created:** [March 14, 2006, 6:14pm UTC](https://www.ruby-forum.com/t/vim-autoindenting-broken/81791 "2006-03-14T18:14:11Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e19b73/32.png) [@jeff](https://www.ruby-forum.com/u/jeff)\
**Post date:** [March 14, 2006, 6:14pm UTC](https://www.ruby-forum.com/t/vim-autoindenting-broken/81791/1 "2006-03-14T18:14:11Z")

</div>

Does anyone else find gVim 6.4 a bit unstable on Windows XP? It’s  
become my editor of choice since learning it recently but I’m noticing  
some peculiar behavior. Last night I spontaneously lost the “Edit in  
vim” context-menu option, at the same time as its autoindenting feature  
changed on its own.

So I can confirm what’s going on, what options control the  
autoindenting?

The behavior I want is for it to indent two spaces after I type  
something like

x = Fred.new(  
indent like this.

and hit Enter.

What I’m seeing is that it indents to the point of the open parenthesis.

x = Fred.new(  
indent like this.

I’m not sure what options govern this or why it changed, because it was  
behaving properly yesterday and I haven’t altered the \_vimrc options.

Thanks,  
Jeff

---

<div class="post-metadata">

**Author:** ![jeff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e19b73/32.png) [@jeff](https://www.ruby-forum.com/u/jeff)\
**Post date:** [March 14, 2006, 9:37pm UTC](https://www.ruby-forum.com/t/vim-autoindenting-broken/81791/2 "2006-03-14T21:37:16Z")

</div>

Jeff C.man wrote:

> something like
> 
> I’m not sure what options govern this or why it changed, because it was  
> behaving properly yesterday and I haven’t altered the \_vimrc options.
> 
> Thanks,  
> Jeff

I have not tried 6.4, but I can say 6.3 is fine on XP. There hasn’t  
really been a new feature that I use in vim since 5.0, so I don’t care  
about having the latest.

~S

---

<div class="post-metadata">

**Author:** ![jeff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e19b73/32.png) [@jeff](https://www.ruby-forum.com/u/jeff)\
**Post date:** [March 15, 2006, 5:47pm UTC](https://www.ruby-forum.com/t/vim-autoindenting-broken/81791/3 "2006-03-15T17:47:33Z")

</div>

Jeff C.man wrote:

> something like
> 
> I’m not sure what options govern this or why it changed, because it was  
> behaving properly yesterday and I haven’t altered the \_vimrc options.
> 
> Thanks,  
> Jeff

I don’t know about your situation, but the latter is what it does for me  
in both vim 6.2 and 6.4, on osx and linux respectively. I didn’t realize  
it was doing this, I seem to remember the former behavior, however I  
prefer the latter behavior so I’m not complaining. I’ve in fact wondered  
how to get it in the past. Not sure if this is a recent ruby-vim change  
or a recent vim change, but if a vim change it’s been around since 6.2  
at least.

---

<div class="post-metadata">

**Author:** ![jeff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e19b73/32.png) [@jeff](https://www.ruby-forum.com/u/jeff)\
**Post date:** [March 18, 2006, 4:15am UTC](https://www.ruby-forum.com/t/vim-autoindenting-broken/81791/4 "2006-03-18T04:15:43Z")

</div>

Jeff C.man wrote:

> Does anyone else find gVim 6.4 a bit unstable on Windows XP? It’s  
> become my editor of choice since learning it recently but I’m noticing  
> some peculiar behavior. Last night I spontaneously lost the “Edit in  
> vim” context-menu option, at the same time as its autoindenting feature  
> changed on its own.  
> I use vim 6.4 all day at work and haven’t noticed anything strange, the  
> edit in vim context menu is always there for me.

> So I can confirm what’s going on, what options control the  
> autoindenting?

If you look in your vim directory under program files, (in the vim64  
folder I belive), you’ll see a directory entitled indent, (or something  
like that). There should be a file in there like ruby.vim. I’m pretty  
sure this is where the indentation for ruby is controlled from.

> The behavior I want is for it to indent two spaces after I type  
> something like
> 
> x = Fred.new(  
> indent like this.
> 
> and hit Enter.

I do this by inserting the lines  
set shiftwidth=2  
set tabstop=2  
set softtabstop=2  
set expandtab

in the aforementioned ruby.vim in the indent directory

> What I’m seeing is that it indents to the point of the open parenthesis.
> 
> x = Fred.new(  
> indent like this.
> 
> I’m not sure what options govern this or why it changed, because it was  
> behaving properly yesterday and I haven’t altered the \_vimrc options.
> 
> Thanks,  
> Jeff

Hope this helps,  
Gary

---

<div class="post-metadata">

**Author:** ![jeff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e19b73/32.png) [@jeff](https://www.ruby-forum.com/u/jeff)\
**Post date:** [March 18, 2006, 4:18am UTC](https://www.ruby-forum.com/t/vim-autoindenting-broken/81791/5 "2006-03-18T04:18:24Z")

</div>

PS, this probably doesn’t matter, but I always insert those lines at the  
bottom of the file so they don’t get overridden by options that appear  
earlier in the file.

Gary

---

<div class="post-metadata">

**Author:** ![jeff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e19b73/32.png) [@jeff](https://www.ruby-forum.com/u/jeff)\
**Post date:** [March 18, 2006, 1:50pm UTC](https://www.ruby-forum.com/t/vim-autoindenting-broken/81791/6 "2006-03-18T13:50:03Z")

</div>

Thanks all,

I’m not sure what happened with the context menus, reinstalling gVim did  
the trick.

I do have another question about vim’s indenting in .rhtml files. I  
find that it tends to shift my lines to places I don’t want them, making  
it hard to keep by program and HTML blocks organized visually. I even  
turned off the auto- and smartindent options in rhtml files, but I still  
noticed the same behavior.

Often I’ll be typing on a line and while I’m typing it will shift the  
line backward a tab stop. Any ideas on how to keep it from doing this?

Thanks again,

Jeff

---

<div class="post-metadata">

**Author:** ![jeff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e19b73/32.png) [@jeff](https://www.ruby-forum.com/u/jeff)\
**Post date:** [March 18, 2006, 7:03am UTC](https://www.ruby-forum.com/t/vim-autoindenting-broken/81791/7 "2006-03-18T07:03:55Z")

</div>

> I do this by inserting the lines  
> set shiftwidth=2  
> set tabstop=2  
> set softtabstop=2  
> set expandtab  
> I generally prefer vim to gvim, but on dos I do go to gvim as it can be  
> quicker to get to than opening a monad shell or the like. I too put the  
> set directives at the bottom of the vimrc file, also important if you’re  
> going to turn your work over to clients or if you have others who edit  
> your files is to put important directives at the top of the file so  
> others don’t mess up your settings, this is the one that I like:

# vim: set expandtab tabstop=2 shiftwidth=2 foldmethod=marker:

That way it comes back to you the way you want it no matter which vimrc  
file it was edited under…

Good Luck with vi, it’s served me well  
Alan
