Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9172371
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:19:48+00:00 2026-06-17T16:19:48+00:00

Vim under Win 7 changes my shiftwidth setting to something I don’t want for

  • 0

Vim under Win 7 changes my shiftwidth setting to something I don’t want for .sml files only.

What I want is everything to be indented with spaces only, and for everything to be 4 spaces always. This is the contents of my current _vimrc file, though I’ve tried many variations:

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

set guifont=Consolas:h9:cANSI
source $VIMRUNTIME/vimrc_example.vim
source $VIMRUNTIME/mswin.vim
behave mswin

filetype plugin indent on

" Set the tab width
let s:tabwidth=4
exec 'set tabstop='    .s:tabwidth
exec 'set shiftwidth=' .s:tabwidth
exec 'set softtabstop='.s:tabwidth

When I first start Vim with no file loaded, :set shiftwidth returns shiftwidth=4. When I open a .py or .php file, it still returns shiftwidth=4. But when I open an .sml file or just save the blank file with an .sml extension, it changes to shiftwidth=2. Manually setting :set shiftwidth=2 works for that session, but I have to do it every time I open an .sml file.

It only affects buffers with an open .sml file. Unsaved buffers or ones with another file type open at the same time show shiftwidth=4.

I wasn’t using the filetype plugin indent thing before, but after some searching it seemed that might be the problem. There were no files in my ftplugin folder, so I added filetype plugin indent on to my _vimrc, created sml.vim and put it in the ftplugin folder (again, having tried many variations:

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

" Set the tab width
let s:tabwidth=4
exec 'set tabstop='    .s:tabwidth
exec 'set shiftwidth=' .s:tabwidth
exec 'set softtabstop='.s:tabwidth

I know sml.vim is being read because I put errors in it at first, and they were caught.

Not sure if this is relevant, but there’s nothing about .sml in my indent.vim, and my indent folder is empty.

Yet Vim still sets shiftwidth=2 every time I load an .sml file. I’d like to know why.

Update: The indent folder that I said was empty was vim\vimfiles\indent. After the answer and comments below I searched for sml.vim and found another indent folder, vim\vim73\indent. I edited sml.vim and changed shiftwidth=2 to shiftwidth=4 and the problem was solved.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T16:19:49+00:00Added an answer on June 17, 2026 at 4:19 pm

    It is most likely due to some filetype plugin. If it was the default one (i.e. shipped with vim itself) the correct fix will be putting appropriate sets

    setlocal ts< sw< sts< " Set ts, sw and sts to global values
    

    ^ into ~/.vim/after/ftplugin/sml.vim. But there is no such settings in vim distribution. In this case the above solution may work (depending on the place where this non-standard plugin is located), but it would be better to examine verb set sw first and check whether plugin that defined &sw is a) the one you really need or b) configurable so that sets can be disabled without using after/ directory.

    Update: It appears it actually is default one, but indent script and not ftplugin as @Nikita Kouevda pointed out. Thus you need to put this line into ~/.vim/after/indent/sml.vim.


    " Set the tab width
    let s:tabwidth=4
    exec 'set tabstop='    .s:tabwidth
    exec 'set shiftwidth=' .s:tabwidth
    exec 'set softtabstop='.s:tabwidth
    

    Use this instead:

    let s:tabwidth=4
    let &tabstop     = s:tabwidth
    let &shiftwidth  = s:tabwidth
    let &softtabstop = s:tabwidth
    

    or

    let [&tabstop, &shiftwidth, &softtabstop]=repeat([4], 3)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want a simple solution to get directory names under a path in vim
When make -ing under Vim, there is often a need to vimgrep the files.
I know they say to store your vim config files under source control. Is
I want to keep my Vim and Emacs configurations under version control, but I
I use vim under iTerm2 in Mac, or putty in windows. I want to
I built a pretty good cygwin setup under Windows7. I installed vim under cygwin.
I got a annoying situation: Under /path1/to, I vim a file name file1, but
I'm writing a Vim script. How can I get the word under the cursor
I am trying to build Vim from the source packages, under Cygwin, to enable
Possible Duplicate: Open file from complete path under cursor in Vim Let's say I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.