Skip to content

Commit 2aab236

Browse files
authored
Merge pull request #1191 from tsuyoshicho/update/20221104/usrx
Update usr_{41,51,52}.txt and usr_{41,52}.jax
2 parents 5f22622 + f5c2913 commit 2aab236

File tree

5 files changed

+75
-48
lines changed

5 files changed

+75
-48
lines changed

doc/usr_41.jax

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*usr_41.txt* For Vim バージョン 9.0. Last change: 2022 Jun 10
1+
*usr_41.txt* For Vim バージョン 9.0. Last change: 2022 Oct 07
22

33
VIM USER MANUAL - by Bram Moolenaar
44

@@ -263,14 +263,14 @@ Note: |Vim9| script を使わずにこれらのコマンドを試すと、旧来
263263
|Vim9| script 内ではスクリプトローカル変数を `unlet` できず、できるのは旧来の
264264
スクリプトの中のみです。
265265

266-
スクリプトの実行が終了したとき、宣言したローカル変数は削除されません。そのスク
267-
リプトで定義された関数が使うことができます。例: >
266+
スクリプトを最後まで処理しきったとき、宣言したローカル変数は削除されません。
267+
のスクリプトで定義された関数が使うことができます。例: >
268268
269269
vim9script
270270
var counter = 0
271271
def g:GetCount(): number
272-
s:counter += 1
273-
return s:counter
272+
counter += 1
273+
return counter
274274
enddef
275275
276276
関数を呼ぶたびに次のカウントを返します: >
@@ -709,6 +709,8 @@ substitute() の呼び出しの前後にいろいろな処理を入れたりす
709709
fnameescape() Vim コマンド用にファイル名をエスケープ
710710
tr() ある文字の集合から別の文字の集合へ置換する
711711
strtrans() 文字列を印字可能な状態とする
712+
keytrans() 内部キーコードから |:map| で使用可能な表記にす
713+
712714
tolower() 文字列を小文字にする
713715
toupper() 文字列を大文字にする
714716
charclass() 文字のクラス
@@ -766,14 +768,16 @@ substitute() の呼び出しの前後にいろいろな処理を入れたりす
766768
reduce() リストの畳み込みの値を算出する
767769
slice() リストのスライスを取る
768770
sort() リストをソートする
769-
reverse() リストの並び順を反転させる
771+
reverse() リストあるいは Blob の並び順を反転させる
770772
uniq() 隣接して繰り返される要素のコピーを削除する
771773
split() 文字列を分割し、リストにする
772774
join() リストの要素を連結し、文字列にする
773775
range() 数列リストを返す
774776
string() リストの文字列表現
775777
call() リストを引数として関数を呼ぶ
776-
index() リスト中の要素のインデックス
778+
index() リストあるいは Blob 中の要素のインデックス
779+
indexof() リストあるいは Blob で式の評価が真となった位置
780+
のインデックス
777781
max() リスト中の最大値
778782
min() リスト中の最小値
779783
count() ある要素がリスト中に出現する回数を返す
@@ -1011,6 +1015,7 @@ Blob 操作: *blob-functions*
10111015
getcmdline() 現在のコマンドラインを取得
10121016
getcmdpos() コマンドラインにおけるカーソル位置を取得
10131017
getcmdscreenpos() コマンドラインでのカーソルの画面位置を取得
1018+
setcmdline() 現在のコマンドラインを設定
10141019
setcmdpos() コマンドラインにおけるカーソル位置を設定
10151020
getcmdtype() 現在のコマンドラインの種類を返す
10161021
getcmdwintype() 現在のコマンドラインウィンドウの種類を返す
@@ -1264,6 +1269,8 @@ Vimサーバー: *server-functions*
12641269
popup_filter_yesno() 'y' か 'n' が押されるまでブロックする
12651270
popup_getoptions() ポップアップの現在のオプションを取得する
12661271
popup_getpos() ポップアップの実際の位置とサイズを取得する
1272+
popup_findecho() `:echowindow` で使用しているポップアップのウィ
1273+
ンドウIDを取得
12671274
popup_findinfo() ポップアップ情報ウィンドウのウィンドウIDを取得
12681275
する
12691276
popup_findpreview() ポップアッププレビューウィンドウのウィンドウID
@@ -1272,6 +1279,14 @@ Vimサーバー: *server-functions*
12721279
popup_locate() スクリーン上の指定の位置にあるポップアップの
12731280
ウィンドウIDを取得する
12741281

1282+
Registers: *register-functions*
1283+
getreg() レジスタの値を得る
1284+
getreginfo() レジスタの情報を得る
1285+
getregtype() レジスタのタイプを得る
1286+
setreg() レジスタの値を設定する
1287+
reg_executing() 実行中のレジスタ名を返す
1288+
reg_recording() 記録中のレジスタ名を返す
1289+
12751290
タイマー: *timer-functions*
12761291
timer_start() タイマーを作る
12771292
timer_pause() タイマーを一時停止もしくは再開する
@@ -1322,6 +1337,7 @@ Vimサーバー: *server-functions*
13221337
did_filetype() FileType自動コマンドが使用されたかどうか
13231338
eventhandler() イベントハンドラによって起動されたかどうか
13241339
getpid() Vim のプロセスIDを得る
1340+
getscriptinfo() 読み込んだ Vim script のリストを取得
13251341
getimstatus() IME のステータスがアクティブかをチェック
13261342
interrupt() スクリプトの実行を中断する
13271343
windowsversion() MS-Windows バージョンの取得
@@ -1333,13 +1349,6 @@ Vimサーバー: *server-functions*
13331349
undofile() アンドゥファイルの名前を得る
13341350
undotree() アンドゥツリーの状態を返す
13351351

1336-
getreg() レジスタの値を得る
1337-
getreginfo() レジスタの情報を得る
1338-
getregtype() レジスタのタイプを得る
1339-
setreg() レジスタの値を設定する
1340-
reg_executing() 実行中のレジスタ名を返す
1341-
reg_recording() 記録中のレジスタ名を返す
1342-
13431352
shiftwidth() 'shiftwidth' の実際の値
13441353

13451354
wordcount() バッファ内のバイト数/単語数/文字数などを得る
@@ -1717,9 +1726,10 @@ range()が生成するリストの最初の要素は0であることに注意し
17171726
==============================================================================
17181727
*41.9* 空白
17191728

1720-
空の行はあっても構いません。無視されます。
1729+
空の行はスクリプト内にあっても構いません。無視されます。
17211730

1722-
行頭の空白 (スペースとTAB) は常に無視されます。
1731+
"trim" 無しで |:let-heredoc| を使用する場合以外、行頭の空白 (スペースとTAB) は
1732+
は無視されます。
17231733

17241734
末尾の空白は多くの場合無視されますが、常にではありません。`map` というコマンド
17251735
は末尾空白を含みます。それに気を付けなくてはいけませんが、分かりにくい間違いを
@@ -1835,13 +1845,16 @@ Unix では特別なコメント書式を使って Vim script を実行形式に
18351845
*41.12* ファイルフォーマット
18361846

18371847
行末の文字はシステムに依存します。Vim script では Unix のファイルフォーマット
1838-
が常に推奨されます。これはまた他のシステムでも動作します。この方法でならあなた
1839-
Vim script を MS-Windows から Unix にコピーしても動くようにすることができま
1840-
|:source_crnl| を参照。確実に正しく設定されるには、ファイルを書き込む前に
1841-
次のようにします: >
1848+
が常に推奨されます。行は改行文字 (注:<NL>) で区切られます。これはまた他のシス
1849+
テムでも動作します。この方法でならあなたの Vim script を MS-Windows から Unix
1850+
にコピーしても動くようにすることができます|:source_crnl| を参照。確実に正し
1851+
く設定されるには、ファイルを書き込む前に次のようにします: >
18421852
18431853
:setlocal fileformat=unix
18441854
1855+
"dos" ファイルフォーマット使用時は、行は CR-NL の二文字で区切られます。CR 文字
1856+
はさまざまな問題の原因なので、これは回避するのが良いです。
1857+
18451858
==============================================================================
18461859

18471860
Vim script を書く事前情報は |usr_50.txt| にあります。

doc/usr_52.jax

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ Vim9 script は大きな Vim script を容易に書けるようにデザイン
162162
163163
これはスクリプト "monthlib.vim" を 'runtimepath' のオートロードディレクトリの
164164
中から検索します。Unix では、ディレクトリの1つが "~/.vim/autoload" であること
165-
が多いです。
165+
が多いです。これはまた 'packpath' の、その下の "start" からも検索します。
166166

167167
この方法の主要な利点として、このスクリプトを他のスクリプトと共有するのが容易で
168168
あることです。Vim が 'runtimepath' 内の "autoload" ディレクトリから検索するた

en/usr_41.txt

Lines changed: 38 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*usr_41.txt* For Vim version 9.0. Last change: 2022 Jun 10
1+
*usr_41.txt* For Vim version 9.0. Last change: 2022 Oct 07
22

33
VIM USER MANUAL - by Bram Moolenaar
44

@@ -268,14 +268,15 @@ when it doesn't, append !: >
268268
You cannot `unlet` script-local variables in |Vim9| script, only in legacy
269269
script.
270270

271-
When a script finishes, the local variables declared there will not be
272-
deleted. Functions defined in the script can use them. Example:
271+
When a script has been processed to the end, the local variables declared
272+
there will not be deleted. Functions defined in the script can use them.
273+
Example:
273274
>
274275
vim9script
275276
var counter = 0
276277
def g:GetCount(): number
277-
s:counter += 1
278-
return s:counter
278+
counter += 1
279+
return counter
279280
enddef
280281
281282
Every time you call the function it will return the next count: >
@@ -322,7 +323,7 @@ want to give the variable a value yet, you need to specify the type: >
322323
323324
If you make a mistake and try to assign the wrong type of value you'll get an
324325
error: >
325-
326+
326327
age = "Peter"
327328
< E1012: Type mismatch; expected number but got string ~
328329

@@ -638,7 +639,7 @@ Make sure that the argument for `normal` is a complete command. Otherwise
638639
Vim will run into the end of the argument and silently abort the command. For
639640
example, if you start the delete operator, you must give the movement command
640641
also. This works: >
641-
642+
642643
normal d$
643644
644645
This does nothing: >
@@ -736,6 +737,8 @@ String manipulation: *string-functions*
736737
fnameescape() escape a file name for use with a Vim command
737738
tr() translate characters from one set to another
738739
strtrans() translate a string to make it printable
740+
keytrans() translate internal keycodes to a form that
741+
can be used by |:map|
739742
tolower() turn a string to lowercase
740743
toupper() turn a string to uppercase
741744
charclass() class of a character
@@ -791,14 +794,16 @@ List manipulation: *list-functions*
791794
reduce() reduce a List to a value
792795
slice() take a slice of a List
793796
sort() sort a List
794-
reverse() reverse the order of a List
797+
reverse() reverse the order of a List or Blob
795798
uniq() remove copies of repeated adjacent items
796799
split() split a String into a List
797800
join() join List items into a String
798801
range() return a List with a sequence of numbers
799802
string() String representation of a List
800803
call() call a function with List as arguments
801-
index() index of a value in a List
804+
index() index of a value in a List or Blob
805+
indexof() index in a List or Blob where an expression
806+
evaluates to true
802807
max() maximum value in a List
803808
min() minimum value in a List
804809
count() count number of times a value appears in a List
@@ -1035,6 +1040,7 @@ Command line: *command-line-functions*
10351040
getcmdpos() get position of the cursor in the command line
10361041
getcmdscreenpos() get screen position of the cursor in the
10371042
command line
1043+
setcmdline() set the current command line
10381044
setcmdpos() set position of the cursor in the command line
10391045
getcmdtype() return the current command-line type
10401046
getcmdwintype() return the current command-line window type
@@ -1283,6 +1289,7 @@ Popup window: *popup-window-functions*
12831289
popup_filter_yesno() block until 'y' or 'n' is pressed
12841290
popup_getoptions() get current options for a popup
12851291
popup_getpos() get actual position and size of a popup
1292+
popup_findecho() get window ID for popup used for `:echowindow`
12861293
popup_findinfo() get window ID for popup info window
12871294
popup_findpreview() get window ID for popup preview window
12881295
popup_list() get list of all popup window IDs
@@ -1307,6 +1314,14 @@ Prompt Buffer: *promptbuffer-functions*
13071314
prompt_setinterrupt() set interrupt callback for a buffer
13081315
prompt_setprompt() set the prompt text for a buffer
13091316

1317+
Registers: *register-functions*
1318+
getreg() get contents of a register
1319+
getreginfo() get information about a register
1320+
getregtype() get type of a register
1321+
setreg() set contents and type of a register
1322+
reg_executing() return the name of the register being executed
1323+
reg_recording() return the name of the register being recorded
1324+
13101325
Text Properties: *text-property-functions*
13111326
prop_add() attach a property at a position
13121327
prop_add_list() attach a property at multiple positions
@@ -1338,6 +1353,7 @@ Various: *various-functions*
13381353
did_filetype() check if a FileType autocommand was used
13391354
eventhandler() check if invoked by an event handler
13401355
getpid() get process ID of Vim
1356+
getscriptinfo() get list of sourced vim scripts
13411357
getimstatus() check if IME status is active
13421358
interrupt() interrupt script execution
13431359
windowsversion() get MS-Windows version
@@ -1349,13 +1365,6 @@ Various: *various-functions*
13491365
undofile() get the name of the undo file
13501366
undotree() return the state of the undo tree
13511367

1352-
getreg() get contents of a register
1353-
getreginfo() get information about a register
1354-
getregtype() get type of a register
1355-
setreg() set contents and type of a register
1356-
reg_executing() return the name of the register being executed
1357-
reg_recording() return the name of the register being recorded
1358-
13591368
shiftwidth() effective value of 'shiftwidth'
13601369

13611370
wordcount() get byte/word/char count of buffer
@@ -1567,7 +1576,7 @@ to "funcref". Example: >
15671576
def Wrong(): string
15681577
return 'Wrong!'
15691578
enddef
1570-
1579+
15711580
var Afunc = g:result == 1 ? Right : Wrong
15721581
echo Afunc()
15731582
< Wrong! ~
@@ -1745,9 +1754,10 @@ For further reading see |Dictionaries|.
17451754
==============================================================================
17461755
*41.9* White space
17471756

1748-
Blank lines are allowed and ignored.
1757+
Blank lines are allowed in a script and ignored.
17491758

1750-
Leading whitespace characters (blanks and TABs) are always ignored.
1759+
Leading whitespace characters (blanks and TABs) are ignored, except when using
1760+
|:let-heredoc| without "trim".
17511761

17521762
Trailing whitespace is often ignored, but not always. One command that
17531763
includes it is `map`. You have to watch out for that, it can cause hard to
@@ -1814,7 +1824,7 @@ is ignored, except for commands that don't consider comments, as shown in
18141824
examples below. A comment can start on any character position on the line,
18151825
but not when it is part of the command, e.g. inside a string.
18161826

1817-
The character " (the double quote mark) starts a comment in legacy script.
1827+
The character " (the double quote mark) starts a comment in legacy script.
18181828
This involves some cleverness to make sure double quoted strings are not
18191829
recognized as comments (just one reason to prefer |Vim9| script).
18201830

@@ -1866,13 +1876,16 @@ script executable, and it also works in legacy script: >
18661876
*41.12* Fileformat
18671877

18681878
The end-of-line character depends on the system. For Vim scripts it is
1869-
recommended to always use the Unix fileformat. This also works on any other
1870-
system. That way you can copy your Vim scripts from MS-Windows to Unix and
1871-
they still work. See |:source_crnl|. To be sure it is set right, do this
1872-
before writing the file: >
1873-
1879+
recommended to always use the Unix fileformat. Lines are then separated with
1880+
the Newline character. This also works on any other system. That way you can
1881+
copy your Vim scripts from MS-Windows to Unix and they still work. See
1882+
|:source_crnl|. To be sure it is set right, do this before writing the file:
1883+
>
18741884
:setlocal fileformat=unix
18751885
1886+
When using "dos" fileformat, lines are separated with CR-NL, two characters.
1887+
The CR character causes various problems, better avoid this.
1888+
18761889
==============================================================================
18771890

18781891
Advance information about writing Vim script is in |usr_50.txt|.

en/usr_51.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ FIRST LINE
7272
>
7373
1 vim9script noclear
7474
75-
You need to use `vimscript` as the very first command. Best is to put it in
75+
You need to use `vim9script` as the very first command. Best is to put it in
7676
the very first line.
7777

7878
The script we are writing will have a `finish` command to bail out when it is
@@ -615,7 +615,7 @@ noremap <script> Only remap mappings defined in this script that start
615615

616616
setlocal Set an option for the current buffer only.
617617

618-
command -buffer Define a user command local to the buffer.
618+
command -buffer Define a user command local to the buffer.
619619

620620
exists("*s:Func") Check if a function was already defined.
621621

en/usr_52.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ relative path: >
159159
160160
This will search for the script "monthlib.vim" in the autoload directories of
161161
'runtimepath'. With Unix one of the directories often is "~/.vim/autoload".
162+
It will also search under 'packpath', under "start".
162163

163164
The main advantage of this is that this script can be easily shared with other
164165
scripts. You do need to make sure that the script name is unique, since Vim

0 commit comments

Comments
 (0)