パーソナルツール

ビジュアルモードの選択情報の取得

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

ビジュアルモードの選択情報の取得

  • ビジュアル選択の範囲の取得
:let pos = getpos(".")

:normal `<
:echo line(".")
:echo col(".")
"# => 選択開始位置を出力

:normal `>
:echo line(".")
:echo col(".")
"# => 選択終了位置を出力

:call setpos('.', pos)
  • ビジュアルモードで選択したテキストを取得する
:let tmp = @@
:silent normal gvy
:let selected = @@
:let @@ = tmp
:echo selected
"# => 選択したテキストを出力
ドキュメントアクション
コメント
blog comments powered by Disqus