Skip to content

Update usr_{41,50,51,52,toc}.{txt,jax} #1118

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 41 commits into from
Oct 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
2c6e534
usr_{41,50,51,52,toc}.txt: Update Vim 8.2.5152
tsuyoshicho Jun 23, 2022
12c90b0
usr_{41,50,51,52,toc}.jax: Update Vim 8.2.5152 translate
tsuyoshicho Jun 26, 2022
59a8238
usr_41.jax: Apply some suggest fix
tsuyoshicho Aug 20, 2022
42bff2c
usr_41.jax: style fix
tsuyoshicho Aug 20, 2022
7b7407e
usr_41.jax: Using new small caption(ja) rule
tsuyoshicho Sep 5, 2022
55efa9e
usr_51.jax: Using new small caption(ja) rule
tsuyoshicho Sep 5, 2022
6f098e1
usr_52.jax: Using new small caption(ja) rule
tsuyoshicho Sep 5, 2022
cd2fea1
usr_41.jax: fix suggestion
tsuyoshicho Sep 8, 2022
df66919
usr_41.jax: apply suggestion
tsuyoshicho Sep 14, 2022
c88e67c
usr_41.jax: typo fix
tsuyoshicho Sep 14, 2022
3f0867b
usr_41.jax: treat translation
tsuyoshicho Sep 17, 2022
fb3aca7
usr_41.jax: fix paragraph
tsuyoshicho Sep 18, 2022
671ebb5
usr_41.jax: apply suggestion
tsuyoshicho Sep 18, 2022
459acb0
usr_41.jax: translate update
tsuyoshicho Sep 19, 2022
ce738ae
usr_50.jax: apply suggestion
tsuyoshicho Sep 22, 2022
fa18e2d
usr_41.jax: update translation
tsuyoshicho Sep 22, 2022
cfb21c4
usr_50.jax: apply suggestion
tsuyoshicho Sep 23, 2022
66d0117
usr_50.txt: Update Vim 9.0.0553
tsuyoshicho Sep 23, 2022
1b5faf9
usr_50.jax: Update Vim 9.0.0553 translate
tsuyoshicho Sep 23, 2022
328ffa4
usr_toc.txt: Update Vim 9.0.0631
tsuyoshicho Oct 1, 2022
5617a64
usr_toc.jax: Update Vim 9.0.0631 translate
tsuyoshicho Oct 1, 2022
65447fb
usr_51.jax: Update some translatitions
tsuyoshicho Oct 1, 2022
89c8b93
usr_51.jax: Fix normal number spacing and folding
tsuyoshicho Oct 1, 2022
46c9921
user_52.jax: Apply all suggested translations
tsuyoshicho Oct 1, 2022
36fa12f
usr_52.jax: Fix 'item' and 'sourced/sourcing' translation
tsuyoshicho Oct 1, 2022
73cb53a
usr_52.jax: typo fix
tsuyoshicho Oct 1, 2022
b3b40e8
usr_52.jax: Apply suggestions
tsuyoshicho Oct 8, 2022
f026db0
usr_41.jax: Apply some suggestions
tsuyoshicho Oct 18, 2022
177831a
usr_50.jax: treat translation
tsuyoshicho Oct 18, 2022
a27f347
usr_41.jax: Update translate and reformat
tsuyoshicho Oct 18, 2022
dae2ee6
usr_50.jax: Update translate and reformat
tsuyoshicho Oct 18, 2022
f973495
usr_41.jax: Update translate and reformat part2
tsuyoshicho Oct 18, 2022
d8f9211
usr_50.jax: Revert Update translate and reformat
tsuyoshicho Oct 18, 2022
fc10718
usr_50.jax: small treat
tsuyoshicho Oct 18, 2022
7c166f0
usr_41.jax: treat translation
tsuyoshicho Oct 18, 2022
1cb83f6
usr_52.jax: Apply many suggestions
tsuyoshicho Oct 22, 2022
676c270
usr_52.jax: fix 'autoload directory'
tsuyoshicho Oct 22, 2022
676b6d9
usr_{51,52,tox}.jax: Update translte for usr_52 title
tsuyoshicho Oct 24, 2022
ac42abb
usr_52.jax: Apply all suggestions
tsuyoshicho Oct 29, 2022
b4ddf30
usr_51.jax: fix source size
tsuyoshicho Oct 29, 2022
4ad73d7
usr_{52,tox}.jax: fix 52.4 title
tsuyoshicho Oct 29, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
522 changes: 228 additions & 294 deletions doc/usr_41.jax

Large diffs are not rendered by default.

116 changes: 110 additions & 6 deletions doc/usr_50.jax
Original file line number Diff line number Diff line change
@@ -1,22 +1,126 @@
*usr_50.txt* For Vim バージョン 9.0. Last change: 2022 May 13
*usr_50.txt* For Vim バージョン 9.0. Last change: 2022 Jun 20

VIM USER MANUAL - by Bram Moolenaar

高度な Vim script の書き方


TODO - この章はいずれ書きます

|50.1| 執筆活動
|50.1| 例外
|50.2| 可変長引数の関数
|50.3| ビューの復元

次章: |usr_51.txt| プラグインを作る
前章: |usr_45.txt| 言語を選択する (ロケール)
目次: |usr_toc.txt|

==============================================================================
*50.1* 執筆活動
*50.1* 例外

まずは例から始めましょう: >

try
read ~/templates/pascal.tmpl
catch /E484:/
echo "パスカル用のテンプレートファイルは見つかりませんでした。"
endtry

`read` コマンドはファイルがなければ失敗します。そのエラーをキャッチして、エラー
メッセージの代わりにより詳細な情報のメッセージを表示しています。

`try` と `endtry` の間で起きたエラーは例外に変換されます。例外は文字列です。エ
ラーの場合、文字列はエラーメッセージを含んでいます。そして、全てのエラーメッ
セージは番号を持っています。この場合、キャッチしたエラーには "E484:" が含まれ
ています。この番号は変わらないことが保証されています (テキストは翻訳されるなど
して変わる可能性があります)。

素敵なエラーメッセージを出力し、Vim は `:endtry` 以降のコマンドの実行も続けま
す。それ以外のキャッチされないエラーに遭遇した場合、スクリプト/関数/マッピング
の実行は中断されます。

`read` コマンドが他のエラーを起こした場合、"E484:" というパターンはマッチしな
いでしょう。したがって、その例外はキャッチされず、通常のエラーメッセージの表示
とともに実行が中断されます。

あなたはこれをしたくなるかもしれません: >

try
read ~/templates/pascal.tmpl
catch
echo "パスカル用のテンプレートファイルは見つかりませんでした。"
endtry

全ての例外がキャッチされます。しかし "E21: Cannot make changes, 'modifiable'
is off" のようなまったく異なる問題を示す有効なエラーに気づくことができません。
エラーをキャッチする前によく考えてください!

もう1つの便利なメカニズムは `finally` コマンドです: >

var tmp = tempname()
try
exe ":.,$write " .. tmp
exe "!filter " .. tmp
:.,$delete
exe ":$read " .. tmp
finally
delete(tmp)
endtry

これは、ファイル名の引数をとる "filter" コマンドを使用して、カーソルからファイ
ルの終わりまでの行をフィルタリングします。フィルタリングが動作しても、`try` と
`finally` の間で何か問題が発生した場合や、ユーザーが CTRL-C を押してフィルタリ
ングをキャンセルした場合は、常に `delete(tmp)` 呼び出しが実行されます。これに
より、一時ファイルを残さないようにすることができます。

`finally` は例外をキャッチせず、エラーはそれ以降の実行を中断します。

例外についてさらに詳しい情報はリファレンスマニュアルの|exception-handling|を
参照してください。

==============================================================================
*50.2* 可変長引数の関数

Vim では、可変数の引数を持つ関数を定義できます。例えば、次のコマンドは、1つの
引数(start)を持つ必要があり、最大20個の追加の引数を持つことができる関数を定義
します: >

def Show(start: string, ...items: list<string>)

変数 "items" は、追加の引数を含む関数内のリストになります。any型のリストと同じ
ように使用できます。例: >

def Show(start: string, ...items: list<string>)
echohl Title
echo "start is " .. start
echohl None
for index in range(len(items))
echon $" Arg {index} is {items[index]}"
endfor
echo
enddef

このように呼び出しできます: >

Show('Title', 'one', 'two', 'three')
< start is Title Arg 0 is one Arg 1 is two Arg 2 is three ~

これは `echohl` コマンドを使用して以降の `echo` コマンドをハイライトするように
指定しています。`echohl None` で再度停止します。`echon` コマンドは `echo` と同
様に動作しますが、改行を出力しません。

引数を1つで呼び出したときは "items" リストは空になります。`range(len(items))`
はインデックス付きのリストを返します。`for` がループするものについては、さらに
詳しく説明します。

==============================================================================
*50.3* ビューの復元

場合によっては、ジャンプして変更を加えてから、同じ位置とビューに戻りたいことが
あります。例えば、ファイルヘッダーの何かを変更します。これは、次の 2 つの関数
で実行できます: >

TODO
var view = winsaveview()
# 移動して、変更を行う
winrestview(view)

==============================================================================

Expand Down
Loading