ActionScript のコードにコメントブロックを挿入する Vim スクリプトを書いた。カーソル位置に任意の文字ブロックを挿入するスマートな方法がよくわからず、泥臭い書き方になった。
function! ASCommentWriter()
let c = col(".")
let l = a:firstline - 1
let s = ''
while len(s) < (c - 1)
let s = s . " "
endwhile
call append(l, s . ' */')
call append(l, s . ' *')
call append(l, s . '/**')
endfunction
autocmd FileType actionscript map <C-c> :call ASCommentWriter()<CR>
適当な関数の先頭行にカーソルを移動して、
private function hoge():void {
}
C-c で、
/**
*
*/
private function hoge():void {
}
こうなる。
訂正してみました。http://vim.g.hatena.ne.jp/ka-nacht/20080625/1214379601
こんにちは。
赤ペン先生、有り難うございます。
autocmd FileType actionscript nnoremap <buffer> <C-c> YPC/**<CR>*<CR>*/<Esc>j^
でスッキリしました!