I've a vim:

VIM - Vi IMproved 8.2 (2019 Dec 12, собрано Apr  8 2020 14:10:43)

and I tried to redefine tabstop, softtabstop and softwidth values for a file after detection of its syntax. I.e. I have a file file.rb with the comment:

# vim:set sw=4 sts=4 ts=4 et:

But the values of the tabstop, softtabstop and softwidth staty the same as they were defined during file type detection, i.e. sw=2 sts=2.

When I forcely try to define the same options at my .vimrc, as:

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

The values say the same, and when I tap a tab key, the cursor is moved to 2 points, instead of 4, during editing file.rb.

So, the question is how to properly change the options even after the file type detection, but when I wish not to fix the vim files manually?

  • Do you have the 'modeline' option disabled? What does :verbose set modeline? tell you? If it's disabled (Vim says nomodeline), then Vim will ignore the modeline from your files with the overrides...
    – filbranden
    Dec 24 '20 at 14:24
  • Also... Do you prefer to do this override through modelines on your *.rb files? Or do you prefer to create local overrides so that Vim will use 4 space indent (overriding the filetype default of 2) for every *.rb file, regardless of a modeline? Please edit your question to include the additional information.
    – filbranden
    Dec 24 '20 at 15:41
  • I have no preferences to redefine, that options, i have tried to change with .vimrc or the modeline, but no effect. But for my projects currently I use modelines Dec 29 '20 at 15:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.