Skip to content

Commit 6a78e66

Browse files
authored
Merge pull request #1330 from vim-jp/hh-update-undo
Update undo.{txt,jax}
2 parents 323125a + c9d49b8 commit 6a78e66

File tree

2 files changed

+47
-10
lines changed

2 files changed

+47
-10
lines changed

doc/undo.jax

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,19 @@ CTRL-G u を使います。挿入コマンドを部分ごと (例えば文単位
111111
にしたい場合に便利です。 |i_CTRL-G_u|
112112

113113
'undolevels' の値を設定したときも undo のブロックが閉じられます。新しい値と古
114-
い値が同じでもそうなります。|Vim9| script では: >
115-
&undolevels = &undolevels
114+
い値が同じでもそうなります。`g:undolevels` を使用して、'undolevels' のグローバ
115+
ル値のみを明示的に読み書きします。|Vim9| script では: >
116+
&g:undolevels = &g:undolevels
116117
旧来のスクリプトでは: >
118+
let &g:undolevels = &g:undolevels
119+
120+
Note 同様に見える代入 `let &undolevels=&undolevels` は、ローカルオプションが別
121+
の値に設定されている場合、グローバルオプションの 'undolevels' 値を保持しないこ
122+
とに注意してください。例えば: >
123+
" 'undolevels' に異なるグローバル値とローカル値を使用して開始する。
124+
let &g:undolevels = 1000
125+
let &l:undolevels = 2000
126+
" この代入により、グローバルオプションが 2000 に変更される。
117127
let &undolevels = &undolevels
118128
119129
==============================================================================
@@ -370,12 +380,21 @@ Vi 互換方式の動作になります。マイナスの値に設定すると u
370380
'undolevels' を -1 に設定しても、undo 情報はすぐにはクリアされません。次の変更
371381
が加えられたときにクリアされます。強制的に undo 情報をクリアしたいときは次のコ
372382
マンドを使ってください: >
373-
:let old_undolevels = &undolevels
374-
:set undolevels=-1
383+
:let old_undolevels = &l:undolevels
384+
:setlocal undolevels=-1
375385
:exe "normal a \<BS>\<Esc>"
376-
:let &undolevels = old_undolevels
386+
:let &l:undolevels = old_undolevels
377387
:unlet old_undolevels
378388
389+
Note `&l:undolevels` を使用して 'undolevels' のローカル値を明示的に読み取り、
390+
`:setlocal` を使用してローカルオプションのみを変更します (対応するグローバルオ
391+
プション値より優先されます)。`&undolevels` を使用してオプション値を保存するこ
392+
とは予測できません。ローカル値 (設定されている場合) またはグローバル値 (ローカ
393+
ル値が設定されていない場合) のいずれかを読み取ります。また、ローカル値が設定さ
394+
れている場合、`:set undolevels` でオプションを変更すると、グローバル値とローカ
395+
ル値の両方が変更され、両方の値を保存および復元するための追加の作業が必要になり
396+
ます。
397+
379398
バッファのマーク ('a から 'z) はテキストと同様に記録、復元されます。
380399

381400
すべての変更を undo したとき、バッファは変更ありとはみなされません。その状態か

en/undo.txt

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,19 @@ use CTRL-G u. This is useful if you want an insert command to be undoable in
111111
parts. E.g., for each sentence. |i_CTRL-G_u|
112112

113113
Setting the value of 'undolevels' also closes the undo block. Even when the
114-
new value is equal to the old value. In |Vim9| script: >
115-
&undolevels = &undolevels
114+
new value is equal to the old value. Use `g:undolevels` to explicitly read
115+
and write only the global value of 'undolevels'. In |Vim9| script: >
116+
&g:undolevels = &g:undolevels
116117
In legacy script: >
118+
let &g:undolevels = &g:undolevels
119+
120+
Note that the similar-looking assignment `let &undolevels=&undolevels` does not
121+
preserve the global option value of 'undolevels' in the event that the local
122+
option has been set to a different value. For example: >
123+
" Start with different global and local values for 'undolevels'.
124+
let &g:undolevels = 1000
125+
let &l:undolevels = 2000
126+
" This assignment changes the global option to 2000:
117127
let &undolevels = &undolevels
118128
119129
==============================================================================
@@ -366,12 +376,20 @@ undo is possible. Use this if you are running out of memory.
366376
When you set 'undolevels' to -1 the undo information is not immediately
367377
cleared, this happens at the next change. To force clearing the undo
368378
information you can use these commands: >
369-
:let old_undolevels = &undolevels
370-
:set undolevels=-1
379+
:let old_undolevels = &l:undolevels
380+
:setlocal undolevels=-1
371381
:exe "normal a \<BS>\<Esc>"
372-
:let &undolevels = old_undolevels
382+
:let &l:undolevels = old_undolevels
373383
:unlet old_undolevels
374384
385+
Note use of `&l:undolevels` to explicitly read the local value of 'undolevels'
386+
and the use of `:setlocal` to change only the local option (which takes
387+
precedence over the corresponding global option value). Saving the option value
388+
via the use of `&undolevels` is unpredictable; it reads either the local value
389+
(if one has been set) or the global value (otherwise). Also, if a local value
390+
has been set, changing the option via `:set undolevels` will change both the
391+
global and local values, requiring extra work to save and restore both values.
392+
375393
Marks for the buffer ('a to 'z) are also saved and restored, together with the
376394
text.
377395

0 commit comments

Comments
 (0)