ファンクションを定義する
作者: 小見 拓
—
最終変更
2012年01月08日 12時09分
ファンクションを定義する
- 単純なファンクション定義サンプル
:function! SimpleFunction() :return "SimpleFunction() is called." :endfunction :echo SimpleFunction() "# => SimpleFunction() is called.
- パラメータを受け取るファンクション
:function! ArgsFunction(var1, var2) :echo "ArgsFunction() is called." :echo "paramter 1 : " . a:var1 :echo "paramter 2 : " . a:var2 :sleep 2 :endfunction :call ArgsFunction("AAA", "BBB") "# => ArgsFunction() is called. "# => paramter 1 : AAA "# => paramter 2 : BBB
- 可変長のパラメータを受け取るファンクション
:function! MArgsFunction(...) :echo "MArgsFunction() is called." :echo "paramter 1 : " . a:1 :echo "paramter 2 : " . a:2 :echo "paramter 3 : " . a:3 :echo "paramter 4 : " . a:4 :echo "paramter 5 : " . a:5 :echo "paramter count : " . len(a:000) :sleep 2 :endfunction :call MArgsFunction("AAA", "BBB", "CCC", "DDD", "EEE") "# => MArgsFunction() is called. "# => paramter 1 : AAA "# => paramter 2 : BBB "# => paramter 3 : CCC "# => paramter 4 : DDD "# => paramter 5 : EEE "# => paramter count : 5
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