I'm writing an SML program and I'm trying to change the size of indents. If I add the following to my .vimrc file

set tabstop=8
set shiftwidth=8
set expandtab

It is not reflected in my actual files. I know this because when I open a .sml file and type :set it reveals that shiftwidth=2

I believe that vim is using a sml plugin because my .vimrc file (similar to the default one) has the following:

if has("autocmd")
" Enable file type detection.
" Use the default filetype settings, so that mail gets 'tw' set to 72,
" 'cindent' is on in C files, etc.
" Also load indent files, to automatically do language-dependent indenting.
filetype plugin indent on

First off, What does if has ("autocmd") mean? And second How can I adjust the default indent size for .sml files? Where might I be able to find this plugin (if this indeed is the issue? I still want to keep the rest of the sml plugin's features.

2 Answers
2

Typing :help autocmd will tell you what autocmd does.
It essentially means that vim can auto execute commands upon certain events.

You can type :echo $VIMRUNTIME to see where vim is storing its system wide plugins.
There will likely be a syntax, indent and ftplugin directory with files that will get autoloaded when an appropriate matching filetype is loaded.

Alternatively these files will be in the same directories underneath your ~/.vim directory

autocmds are special commands triggered on specific events or on specific filetypes. They are often used to set options or define mappings that make sense in one language but not in others.

Since autocmds are widely used for filetype specific stuff, if has("autocmd") is a way to test if the autocmd feature is available and that we can go further without much risk.

The right location for storing filetype-specific settings is ~/.vim/after/ftplugin/<filetype>.vim, so you should write your settings in:

~/.vim/after/ftplugin/sml.vim

This file is sourced by Vim after the default ftplugin so you can, for example, change only the value of tabstop and keep the other settings.

However, looking at my own Vim runtime (/usr/share/vim/vim73) it looks like there's no ftplugin for sml. This means that ~/.vim/ftplugin/sml.vim would be an equally right choice of location. Pick the one you like.