1

There is a line in defaults.vim that enables Vim Script syntax for any .txt file with vimrc in its filename (for example, vimrc-tips.txt):

au BufNewFile,BufRead *vimrc*           call s:StarSetf('vim')

I want to replace *vimrc* with *vimrc or maybe even with a regular expression that will allow only the period or underscore as the first character.

For this, if understnad correctly, I need to disable the original autocommand first.

I tried to disable it with

" see https://stackoverflow.com/questions/25829710
augroup standard
  autocmd!
  autocmd BufNewFile,BufRead *vimrc* setlocal setfiletype disabled
augroup END

The idea is that this should disable treating files like vimrc-tips.txt as Vim Script files, but at the same time this should not disable syntax for _vimrc, .vimrc, or any other files (for example, foo.md or bar.js).

But this doesn't disable syntax for files like vimrc-tips.txt, and even worse when I open such a file, there is a message:

Press ENTER or type command to continue

How this should be fixed?

1 Answer 1

1
  1. The line in question is in $VIMRUNTIME/filetype.vim, not in defaults.vim.

  2. You can override it by creating the following file:

    ~/.vim/ftdetect/vimtxt.vim
    

    with this content:

    autocmd BufNewFile,BufRead *vimrc*.txt setfiletype text
    

Note that the autocommand in the linked answer is broken.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.