1

How can I get my vim to apply the autocmd without manual reloading of ~/.vimrc? And why is the ... Filetype tsv ... never applied at all?

My ~/.vimrc

set ts=10
autocmd BufWrite * :echom "Writing buffer!"
autocmd Filetype tsv set ts=20 sts=20 sw=20

~/.vimrc is loaded, however the autocmd is applied only after a :so:

$ vim /tmp/test.tsv
:verbose set ts
  tabstop=10
    Last set by ~/.vimrc
:w
"test.tsv" 2L, 37C written
:so ~/.vimrc
:w
Writing buffer!
"test.tsv" 2L, 37C written

Also, why is the tabstop not set to 20 even though I edit a .tsv file?

vim --version: VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Jul 11 2015 08:43:46)

:scriptnames:

  1: /etc/vimrc
  2: /usr/share/vim/vimfiles/archlinux.vim
  3: ~/.vimrc
  4: ~/.vim/plugin/InsertXSDDateTimeLiteral.vim
  5: ~/.vim/plugin/RdfNamespaceComplete.vim
  6: /usr/share/vim/vimfiles/plugin/SyntaxFolds.vim
  7: /usr/share/vim/vimfiles/plugin/filebrowser.vim
  8: /usr/share/vim/vimfiles/plugin/imaps.vim
  9: /usr/share/vim/vimfiles/plugin/libList.vim
 10: /usr/share/vim/vimfiles/plugin/remoteOpen.vim
 11: /usr/share/vim/vim74/plugin/getscriptPlugin.vim
 12: /usr/share/vim/vim74/plugin/gzip.vim
 13: /usr/share/vim/vim74/plugin/logiPat.vim
 14: /usr/share/vim/vim74/plugin/matchparen.vim
 15: /usr/share/vim/vim74/plugin/netrwPlugin.vim
 16: /usr/share/vim/vim74/plugin/rrhelper.vim
 17: /usr/share/vim/vim74/plugin/spellfile.vim
 18: /usr/share/vim/vim74/plugin/tarPlugin.vim
 19: /usr/share/vim/vim74/plugin/tohtml.vim
 20: /usr/share/vim/vim74/plugin/vimballPlugin.vim
 21: /usr/share/vim/vim74/plugin/zipPlugin.vim
Konrad Höffner
  • 11,100
  • 16
  • 60
  • 118
  • 1
    If I create a vimrc with only the 3 lines that you posted, I get the "Writing buffer" message even if don't source the vimrc manually. So it must be one of your plugins or other things in your .vimrc overwriting this – edi9999 Aug 19 '15 at 11:35

1 Answers1

2

For the filetype problem, it is probably because vim doesn't know about the "tsv" file type : you can check that by running :set filetype which will return you the current filetype. (It returns "" for me on a *.tsv file)

The following will work for all *.tsv files

autocmd BufEnter *.tsv set ts=20 sts=20 sw=20

Fot the other problem, it must be one of your plugins or other things in your .vimrc overwriting this (because it works with only those three lines in the vimrc). Try to find the culprit by running :autocmd which will list all registered autocommands

edi9999
  • 19,701
  • 13
  • 88
  • 127
  • The TSV setting worked perfectly, thanks! For the :autocmd, the output is really long and I don't know what to look for but that question was only for debugging the first problem so is not necessary to resolve. – Konrad Höffner Aug 19 '15 at 12:11