Skip to content

Instantly share code, notes, and snippets.

@kana
Created June 28, 2009 03:03
Show Gist options
  • Save kana/137190 to your computer and use it in GitHub Desktop.
Save kana/137190 to your computer and use it in GitHub Desktop.
vim -u NONE -c 'source test.vim'
Before Syntax * = /
:edit a.vim
Before FileType * = vim/vim
FileType vim on a.vim
Before Syntax * = vim/vim
After Syntax * = vim/vim
After FileType * = vim/vim
:edit xyzzy
:setfiletype vim
Before FileType * = vim/vim
FileType vim on xyzzy
Before FileType * = html/html
Before Syntax * = html/html
After Syntax * = html/html
After FileType * = html/html
Before Syntax * = html/vim
After Syntax * = html/vim
After FileType * = html/vim
autocmd FileType vim
\ call add(g:message, 'FileType vim on '.expand('%'))
\ | if expand('%') ==# 'xyzzy'
\ | setlocal filetype=html
\ | endif
set nocompatible
let g:message = []
augroup testBefore
autocmd FileType *
\ call add(g:message, 'Before FileType * = '.&l:filetype.'/'.expand('<amatch>'))
autocmd Syntax *
\ call add(g:message, 'Before Syntax * = '.&l:filetype.'/'.expand('<amatch>'))
augroup END
syntax enable
augroup testAfter
autocmd FileType *
\ call add(g:message, 'After FileType * = '.&l:filetype.'/'.expand('<amatch>'))
autocmd Syntax *
\ call add(g:message, 'After Syntax * = '.&l:filetype.'/'.expand('<amatch>'))
augroup END
call add(g:message, ':edit a.vim')
edit a.vim
call add(g:message, ':edit xyzzy')
edit xyzzy
call add(g:message, ':setfiletype vim')
setfiletype vim
put =g:message
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment