> i found solutions online on how to do indentation based on a filetype
> however none of them worked except the last one. i would really
> appreciate if someone could explain to me what was i doing wrong.
>
> here are the solutions that didn't work
> my .vimrc contains
> set shiftwidth=2
> set tabstop=2
>
If you really mean filetype-based *indentation* (as in, Vim
automatically indents the file for you, as you type), then you will
also want:
filetype indent on
or:
filetype indent plugin on
Even if this is not what you are after, for the most likely solution
to your problem, you will need at least:
filetype plugin on
or:
filetype on
> solution1:
>
> ~/.vim/ftdetect/mine.vim
> setlocal shiftwidth=4
> setlocal tabstop=4
>
This will not work. First of all, the ftdetect directory is for rules
which ALWAYS run on EVERY new file, in order to DETECT the filetype
"mine". This is NOT the place for filetype-specific settings. The
correct place is the ftplugin directory, not the ftdetect directory.
Even with this, however, since your .vimrc does not contain a filetype
[indent] [plugin] on, these files will probably not run at all.
> ~/.vimrc
> au BufRead,BufNewFile *.mine set filetype=mine
>
This should be totally unnecessary if you've turned on filetype
detection in your .vimrc, and placed rules for detecting your filetype
in ftdetect.
> solution2:
>
> ~/.vim/after/ftdetect/mine.vim
> setlocal shiftwidth=4
> setlocal tabstop=4
>
> au BufRead,BufNewFile *.mine set filetype=mine
>
This solution fails for the same reasons listed above.
> solution3:
> autocmd FileType mine setlocal shiftwidth=4 tabstop=4
>
This would work, except that you don't seem to have filetype detection
turned on.
> the following solution worked
> Solution 4:
> ~/.vim/after/ftplugin/mine.vim
> setlocal shiftwidth=4
> setlocal tabstop=4
>
> ~/.vimrc
> au BufRead,BufNewFile *.mine set filetype=mine
>
This solution works because although you don't have filetype detection
turned on, you are triggering a filetype (which apparently runs the
ftplugin? weird), and have the settings in one of a couple proper
places.
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
No comments:
Post a Comment