> I am trying to test for filetype '.bat' in _vimrc and set syntax off. I tried
> adding the following to _vimrc but it does not work:
>
> if v:fname_in =~ '.bat$'
> syntax off
> end if
>
> I echoed v:fname_in and it was NULL. I also echoed v:fname_out and it was also
> NULL. That seems strange. Can someone offer a solution?
Help for v:fname_in and v:fname_out says that these values are valid
only in certain contexts, such as in 'diffexpr'. Those contexts
don't include one's _vimrc.
The commands in _vimrc are executed before any files on vim's
command line are opened. If you have some commands that you want
executed for only certain file types, it is better to execute those
commands as autocommands or to put them in filetype plugins. The
former may appear easier, but it can be tricky to get autocommands
to execute in the proper sequence. If you're not sure what you're
doing, it's probably safer to put any filetype-dependent commands in
your vimfiles\after\ftplugin directory. In this case, the file name
would be
dosbatch.vim
The vimfiles directory can be a subdirectory of $HOME or of $VIM.
Are you sure you want to set "syntax off"? That will turn off
syntax highlighting for all buffers. It seems more likely that you
want it turned off only for buffers containing .bat files. That
command would be
setlocal syntax=OFF
In summary, I would solve your problem by putting the line above in
the file
$HOME\vimfiles\after\ftplugin\dosbatch.vim
(To be consistent, I suppose I should have used %HOME% instead of
$HOME, but Vim uses $HOME internally.)
HTH,
Gary
--
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