ファイルに書かれたpythonのコードを実行する
作者: 小見 拓
—
最終変更
2012年01月08日 12時13分
ファイルに書かれたpythonのコードを実行する
「:pyfile」コマンドで実行ファイルを指定する。
- pythonのスクリプトファイル
#!/usr/bin/python print "Hello Python"
- vimスクリプト側
:pyfile hello.py "# => Hello Python
スクリプトにコマンドライン引数を渡す
- pythonのスクリプトファイル
#!/usr/bin/python import sys i = 0 while i < len(sys.argv): print "argument " + str(i + 1) + " is " + sys.argv[i] i += 1
- vimスクリプト側
" 「:python」コマンドを使用して引数を渡す :python import sys :python sys.argv = ("ARG1", "ARG2", "ARG3") :pyfile arg.py "# => argument 1 is ARG1 "# => argument 2 is ARG2 "# => argument 3 is ARG3 " この方法ではコマンドライン引数を渡せない :pyfile arg.py ARG1 ARG2 ARG3 "# => エラー
Recent Comments
ありがとうございます!
http://nanasi.jp/articles/howto/editing/visualcursor-endtoend.html · 8 years ago
知りませんでした。有難うございました。
http://nanasi.jp/articles/howto/file/open-with-format.html · 9 years ago
<c-f>1ページ分、下にスクロールする<c-b>1ページ分、上にスクロールする
どっちも逆です。
http://nanasi.jp/articles/howto/user-manual/user-manual-motion.html · 10 years ago
set 使用時に : で閉じるのを忘れて右往左往してました。
http://nanasi.jp/articles/howto/file/modeline.html · 11 years ago
やっぱり日本語の方が早いっす。
http://nanasi.jp/articles/howto/help/help_ja.html · 12 years ago