swilliams
swilliams

Reputation: 48910

How do I override the default tabindent for Ruby in Vim?

I'm using Janus for vim and am really liking it, but I can't seem to get my preferred tabstop of 4 working right. This is in my .vimrc

set tabstop=4
set shiftwidth=4
set softtabstop=4
set expandtab

Later on I have

filetype plugin indent on

But all of my ruby files keep using the default version of 2, which I just don't like. I've tried following the instructions on this page, including creating a ruby.vim file in the after folder (and in the indent folder that janus created). I've added:

au FileType ruby set softtabstop=4 tabstop=4 shiftwidth=4

to my .vimrc, but none of those work.

I can manually call set tabstop, etc from command mode, which works, but that's not a great solution.

What's missing?

Upvotes: 9

Views: 3655

Answers (6)

swilliams
swilliams

Reputation: 48910

Xavier T's comment provided the answer, but since he didn't actually make an answer, here it is:

Can you try :verbose set tabstop sw softtabstop expandtab ?. It should tell which script is modifying your value of 4.

This lead me to see that autoload/rails.vim was what was setting the tab spacing back.

Upvotes: 6

Mike Lee
Mike Lee

Reputation: 1215

Just create a file ~/.vimrc.after

within the file, set tab to 4 spaces set tabstop=4

Then janus will load the .vimrc.after file after janus

Upvotes: 0

piotrb
piotrb

Reputation: 364

As per (at least the current version) of Janus ..

The preferred way to override settings is to edit ~/.vimrc.after

This file gets loaded after all of Janus stuff and whatever you put in there should override any settings set elsewhere.

Upvotes: 1

richo
richo

Reputation: 8989

https://github.com/richoH/dotfiles/blob/master/vimrc

Lines 141-160.

It's a fairly crude approach, originally it did a few other things. It needs refactoring, but this ought to give you enough to go with.

Upvotes: 0

Lloyd Moore
Lloyd Moore

Reputation: 3197

Once you are inside vim, run :set tabstop and it will show you what it was last set to. If this is different from what you expect it means that it is being overwritten. To debug, use find or ack (my personal favourite) to find all files that have the word tabstop. A good place to start is inside your .vimrc folder and run ack -l tabstop.

Upvotes: 0

Andrea Pavoni
Andrea Pavoni

Reputation: 5311

If I'm not wrong, that setting is found in tpope's ruby/rails plugin. I'm not sure, but if you try to set your tab settings at the end of .vimrc, they should work.

also, give a check at .gvimrc, especially if you're using macvim/gvim

Upvotes: 0

Related Questions