パーソナルツール

呼び出されたpythonのコードから、vimのデータを変更する

作者: 小見 拓 最終変更 2012年01月08日 12時13分

呼び出されたpythonのコードから、vimのデータを変更する

  • カレント行テキストを変更する
# -*- coding: shift_jis -*-
from vim import *
current.line = "カレント行テキストの変更"
  • 選択範囲テキストを変更する
# -*- coding: shift_jis -*-
from vim import *

# 選択範囲3行目のデータを変更
current.range[2] = "選択範囲3行目のデータを変更"
# -*- coding: shift_jis -*-
from vim import *
import vim

# 選択範囲のテキストを全て変更
current.range[:] = [ "head:" + i for i in current.range ]
  • カレントバッファのテキストを変更する
# -*- coding: shift_jis -*-
from vim import *

# 3行目のデータを変更
current.buffer[2] = "3行目のデータを変更"
# -*- coding: shift_jis -*-
from vim import *
import vim

# カレントバッファのテキストを全て変更
current.buffer[:] = [ "head:" + i for i in current.buffer ]
ドキュメントアクション
コメント
blog comments powered by Disqus