AutoProtectFile.vim
以前書いた system runtime file を開いたら自動で readonly にする plugin なんだけど ( http://d.hatena.ne.jp/janus_wel/20090227/1235740243 ) 見事にだまされたので ( http://vim.wikia.com/wiki/Change_filetype_based_on_directory_path を参考にして書いたんだけど autocmd の BufRead event で十分だったというオチ。ってかこの page の下の方にも冗長だって書いてあるからちゃんと読んでないおれが悪いんだけど。なら削除しといて欲しいと思うのが人情さね ) 書き換えるついでに機能を足してみた。
vimrc で以下のそれぞれの変数に path をつっこむと readonly / nomodifiable にしてくれるという plugin 。複数指定は comma 区切りで。 nomodifiable は help とかと同じように buffer 内容の変更すらもできなくする local option 。
- g:autoprotectfile_readonly_paths
- readonly にする path
- g:autoprotectfile_nomodifiable_paths
- nomodifiable にする path
default だと何もしない。設定例は以下の感じで。
let g:autoprotectfile_readonly_paths = "$VIMRUNTIME/*,~/important" let g:autoprotectfile_nomodifiable_paths = "~/important"