2013-04-20

palindrome mode

vimでpalindrome modeその1。

拡張子.pdmのファイルに対してpalindrome modeを設定し、
取り敢えず、文字入力に対して引っくり返した文字も入力する。
<BS>と<Del>も追加。

augroup palindrome
autocmd!
autocmd Bufread,BufNewFile *.pdm setlocal filetype=palindrome
autocmd FileType palindrome call s:map_palindrome()
function! s:map_palindrome()
for i in range(65,122)+range(33439,33521)
execute printf("inoremap <buffer> <Char-%d> <Char-%d><Char-%d><Left>",i,i,i)
endfor
endfunction
autocmd FileType palindrome inoremap <buffer> <BS> <BS><Del>
autocmd FileType palindrome inoremap <buffer> <Del> <Del><BS>
augroup END
これを.vimrcに追加して、:e test.pdm等とすると、palindrome modeで編集できる。
gateman's
と入力すれば、
gateman'ssnametag
になるので、normal modeに戻ってlr<Space>とすれば
gateman's nametag
となって回文が作れる。

2013-04-20 19:42現在の戦闘力: 246

No comments:

Post a Comment