.as のテンプレート周りをさらに改良。XxxEvent.as のように Event.as で終わるファイル名ならば Event クラス用のテンプレートを読むようにした。
gvimrc
au BufRead,BufNewFile *.as call LoadASTemplate() function! LoadASTemplate() if (line("$") == 1) && (match(getline(1), "^$") == 0) let className = substitute(expand("%:t"), "\.as", "", "") "Windows if (match(className, "Event$") == -1) 0r $HOME/vimfiles/templates/template.as exe "%s/Main/" . className . "/g" else 0r $HOME/vimfiles/templates/event-template.as exe "%s/CustomEvent/" . className . "/g" endif echo className endif endfun
event-template.as
package { import flash.events.Event; /** * * @author */ public class CustomEvent extends Event { /** * コンストラクタ * @param type イベントタイプ */ public function CustomEvent(type:String) { super(type); } } }
:e HogeEvent.as
で
package { import flash.events.Event; /** * * @author */ public class HogeEvent extends Event { /** * コンストラクタ * @param type イベントタイプ */ public function HogeEvent(type:String) { super(type); } } }
となる。