GVim mini Tips
Posted on Thu, 12 Mar 2009 23:46:10 +0900
先日 はお酒の勢いで、変なことしゃべっちゃいました。少し反省。
今日は小さなTipsをひとつふたつ。 Windows GVim の設定をHackしてみた。 (MacOSX(MacVim)でも使えるかも。)
browse confirm saveas を save コマンドとして実行する
gvimrcに以下を追記します。
ca save browse confirm saveas
:save
で、保存用のウインドウが開きます。 ca はコマンドの短縮コマンド登録ですね。
rst形式ファイル編集中にrst2htmlしてWebブラウザで表示
reStructuredText形式ファイルを開いているときに、 rst2htmlを実行した結果をWebブラウザで表示してくれる設定です。
runtime\ftplugin\rst.vim に以下を追加します。(かなり適当)
python << EOF
from docutils.core import publish_file
import os
import tempfile
import time
import webbrowser
import vim
def Rst2Web():
src_fo = open(vim.buffers[0].name)
dst = tempfile.mkstemp(suffix='.html')
dst_fo = os.fdopen(dst[0], 'w')
dst_filename = dst[1]
print dst_filename
out = publish_file(src_fo, '.', dst_fo, '.', writer_name='html')
webbrowser.open(dst_filename)
time.sleep(3)
os.remove(dst_filename)
EOF
ca rst2web :py Rst2Web()
time.sleep() しているところとかは、ちょっとイケテナイですね。
:rst2web
を実行すればOKです。