Skip to content

Commit fe1c81c

Browse files
committed
Update usr_25.{txt,jax}
1 parent bebc82b commit fe1c81c

File tree

2 files changed

+87
-74
lines changed

2 files changed

+87
-74
lines changed

doc/usr_25.jax

Lines changed: 44 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*usr_25.txt* For Vim バージョン 9.1. Last change: 2025 Feb 01
1+
*usr_25.txt* For Vim バージョン 9.1. Last change: 2025 Jun 10
22

33
VIM USER MANUAL - by Bram Moolenaar
44

@@ -207,29 +207,29 @@ Note: 特定の書式に従った文章なら自動的に整形することも
207207
*25.3* インデントとタブ
208208

209209
テキストをインデントすればその部分を目立たせることができます。例えばこのマニュ
210-
アルでは、例文を示すときに 8 個のスペースまたは Tab 文字でインデントしていま
211-
す。通常なら行頭で Tab キーを押せばインデントできます。例:
210+
アルでは、例文を示すときに 8 カラムでインデントしています。通常なら行頭で
211+
<Tab> を押せばインデントできます。例:
212212

213213
the first line ~
214214
the second line ~
215215

216-
Tab キーを押してテキストを挿入、<Enter>、また Tab キーを押してテキストを挿入し
217-
ます。
216+
これは、<Tab>、テキスト、<Enter><Tab>、さらにテキストをタイプして入力します。
218217
'autoindent' オプションを設定すると、自動的にインデントできます: >
219218
220219
:set autoindent
221220
222-
新しい行を開始すると、直前の行と同じだけのインデントが挿入されます。上の例な
223-
<Enter> を押した後の Tab キーが必要なくなります
221+
新しい行を開始すると、直前の行と同じだけのインデントが挿入されます。上記の例で
222+
<Enter> の後に <Tab> キーを押す必要はなくなりました
224223

225224

226225
☆インデントを増やす
227226

228-
行のインデント量を増やすには ">" オペレータを使います。現在行のインデントを増
229-
やしたい場合は ">>" を使うと簡単です。
227+
行のインデントを増やすには、ノーマルモードで ">" 演算子を使用します。これは多
228+
くの場合、">>" のように使用され、現在の行にインデントを追加します。挿入モード
229+
では <C-t> を使用します。
230230
インデントの増加量は 'shiftwidth' オプションで設定できます。初期設定は 8 です。
231-
例えば、">>" でスペース 4 つ分のインデントを増やしたい場合は次のように設定しま
232-
: >
231+
例えば、">>" でスペース 4 カラム分のインデントを増やしたい場合は次のように設定
232+
します: >
233233
234234
:set shiftwidth=4
235235
@@ -241,44 +241,25 @@ Tab キーを押してテキストを挿入、<Enter>、また Tab キーを押
241241
"4>>" は四つの行のインデントを増やすコマンドです。
242242

243243

244-
タブストップ
244+
ソフトタブストップ
245245

246-
インデントを 4 桁にしたい場合は 'shiftwidth' を 4 に設定します。しかしそれだけ
247-
では、<Tab> を押したときのインデントの量はスペース 8 個分のままです。これを変
248-
更するには 'softtabstop' オプションを設定します: >
246+
インデントを 4 桁にしたい場合は 'shiftwidth' を 4 に設定します。ただし、<Tab>
247+
キーを押すと、8 カラム分のインデントが保持されます。これを変更するには
248+
'softtabstop' オプションを設定します: >
249249
250250
:set softtabstop=4
251251
252-
これで、<Tab> キーがスペース 4 個分のインデントになります。既に 4 つスペースで
253-
インデントされている場合は <Tab> 文字に置き換えられます (7 バイト節約)。(Tab
254-
文字を使いたくない場合は 'expandtab' を設定してください。)
252+
Vim は 4 カラムごとにカーソルに目に見えないタブストップを作成するようになりま
253+
した。<Tab> を押すと次のストップにジャンプし、必要なスペースまたはタブの正確な
254+
組み合わせが挿入されます。
255255

256256
Note:
257257
'tabstop' オプションを 4 に設定することもできますが、その設定で編集し
258258
たファイルを 'tabstop' の初期設定 (8) で見ると見た目が崩れてしまいま
259259
す。他のプログラムで印刷する場合もインデントが崩れてしまうかもしれませ
260-
ん。したがって、'tabstop' は常に 8 のままにしておきましょう。それが標
261-
準的な値です。
262-
263-
264-
☆TAB幅を変更する
260+
ん。したがって、'tabstop' は常に 8 のままにしておきましょう。UNIX 系シ
261+
ステムの場合、それが標準的な値です。
265262

266-
tabstop が 3 で書かれたファイルを (tabstop が 8 の) Vim で開くと表示が崩れてし
267-
まいます。'tabstop' を 3 に設定すれば表示を直すことができますが、ファイルを開
268-
くたびに設定を変更しなければなりません。
269-
ファイルの tabstop 幅を変更することができます。インデントが正しく表示されるよ
270-
うに 'tabstop' を設定してから ":retab" コマンドを使います: >
271-
272-
:set tabstop=3
273-
:retab 8
274-
275-
":retab" コマンドを使って 'tabstop' を 8 に変更しています。ただし、テキストの
276-
見た目は変更されません。空白部分が Tab 文字とスペースに置き換えられます。その
277-
状態でファイルを保存すれば、次からは設定を変更しなくてもインデントが正しく表示
278-
されます。
279-
警告: プログラムに対して ":retab" を使った場合、文字列定数の中の空白記号が変更
280-
されてしまうかもしれません。文字列定数の中では Tab 文字ではなく "\t" を使うよ
281-
うにしましょう。
282263

283264
==============================================================================
284265
*25.4* 長い行の扱い
@@ -551,6 +532,30 @@ Tab 文字が挿入されてます。
551532

552533
inp 0.786 0.534 0.693 ~
553534

535+
536+
☆テーブル内のタブを再フォーマットする
537+
538+
表形式のデータを含むファイルを編集しているのですが、ファイルの元の作成者は、表
539+
形式のデータを (スペースではなく) タブ文字で整列させることに決めていました。
540+
なんと、タブ区切りの文字は4列でしたが、Vimのデフォルトは8列です。表の見た目が
541+
おかしくなってしまいます! どうすればいいでしょうか?
542+
ファイルを変更せずに見栄えを修正するには、一時的に設定を調整します: >
543+
544+
:set tabstop=4
545+
546+
これによりレイアウトは更新されますが、ファイル自体は変更されません。
547+
もう 1 つの方法は、ファイルを恒久的に再フォーマットすることです。そのためには、
548+
Vim には |:retab| コマンドが用意されています。まず、'tabstop' を元のレイアウト
549+
に合わせて (上記のように) 設定し、以下を実行します: >
550+
551+
:retab 8
552+
553+
":retab" コマンドを使って 'tabstop' を 8 に変更しています。ただし、テキストの
554+
見た目は変更されません。空白部分が Tab 文字とスペースに置き換えられます。
555+
警告: プログラムに対して ":retab" を使った場合、文字列定数の中の空白記号が変更
556+
されてしまうかもしれません。文字列定数の中では Tab 文字ではなく "\t" を使うよ
557+
うにしましょう。
558+
554559
==============================================================================
555560

556561
次章: |usr_26.txt| 繰り返し

en/usr_25.txt

Lines changed: 43 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*usr_25.txt* For Vim version 9.1. Last change: 2025 Feb 01
1+
*usr_25.txt* For Vim version 9.1. Last change: 2025 Jun 10
22

33
VIM USER MANUAL - by Bram Moolenaar
44

@@ -215,27 +215,28 @@ An alternative is to filter the text through an external program. Example: >
215215
*25.3* Indents and tabs
216216

217217
Indents can be used to make text stand out from the rest. The example texts
218-
in this manual, for example, are indented by eight spaces or a tab. You would
219-
normally enter this by typing a tab at the start of each line. Take this
218+
in this manual, for example, are indented by eight columns. You would
219+
normally enter this by typing <Tab> at the start of each line. Take this
220220
text:
221221
the first line ~
222222
the second line ~
223223

224-
This is entered by typing a tab, some text, <Enter>, tab and more text.
224+
This is entered by typing <Tab>, some text, <Enter>, <Tab> and more text.
225225
The 'autoindent' option inserts indents automatically: >
226226
227227
:set autoindent
228228
229229
When a new line is started it gets the same indent as the previous line. In
230-
the above example, the tab after the <Enter> is not needed anymore.
230+
the above example, pressing the <Tab> key after <Enter> is not needed anymore.
231231

232232

233233
INCREASING INDENT
234234

235-
To increase the amount of indent in a line, use the ">" operator. Often this
236-
is used as ">>", which adds indent to the current line.
235+
To increase the amount of indent in a line, use the ">" operator, in Normal
236+
mode. Often this is used as ">>", which adds indent to the current line.
237+
In Insert mode, use <C-t>.
237238
The amount of indent added is specified with the 'shiftwidth' option. The
238-
default value is 8. To make ">>" insert four spaces worth of indent, for
239+
default value is 8. To make ">>" insert four columns worth of indent, for
239240
example, type this: >
240241
241242
:set shiftwidth=4
@@ -248,46 +249,27 @@ When used on the second line of the example text, this is what you get:
248249
"4>>" will increase the indent of four lines.
249250

250251

251-
TABSTOP
252+
SOFT TAB STOPS
252253

253254
If you want to make indents a multiple of 4, you set 'shiftwidth' to 4. But
254-
when pressing a <Tab> you still get 8 spaces worth of indent. To change this,
255-
set the 'softtabstop' option: >
255+
when pressing a <Tab> you still get 8 columns worth of indent. To change
256+
this, set the 'softtabstop' option: >
256257
257258
:set softtabstop=4
258259
259-
This will make the <Tab> key insert 4 spaces worth of indent. If there are
260-
already four spaces, a <Tab> character is used (saving seven characters in the
261-
file). (If you always want spaces and no tab characters, set the 'expandtab'
262-
option.)
260+
Vim now creates invisible tab stops for your cursor every 4 columns; hitting
261+
<Tab> jumps to the next stop and inserts the exact mix of spaces or tabs
262+
needed.
263263

264264
Note:
265265
You could set the 'tabstop' option to 4. However, if you edit the
266266
file another time, with 'tabstop' set to the default value of 8, it
267267
will look wrong. In other programs and when printing the indent will
268268
also be wrong. Therefore it is recommended to keep 'tabstop' at eight
269-
all the time. That's the standard value everywhere.
269+
all the time. That's the standard value everywhere on UNIX-like
270+
systems.
270271

271272

272-
CHANGING TABS
273-
274-
You edit a file which was written with a tabstop of 3. In Vim it looks ugly,
275-
because it uses the normal tabstop value of 8. You can fix this by setting
276-
'tabstop' to 3. But you have to do this every time you edit this file.
277-
Vim can change the use of tabstops in your file. First, set 'tabstop' to
278-
make the indents look good, then use the ":retab" command: >
279-
280-
:set tabstop=3
281-
:retab 8
282-
283-
The ":retab" command will change 'tabstop' to 8, while changing the text such
284-
that it looks the same. It changes spans of white space into tabs and spaces
285-
for this. You can now write the file. Next time you edit it the indents will
286-
be right without setting an option.
287-
Warning: When using ":retab" on a program, it may change white space inside
288-
a string constant. Therefore it's a good habit to use "\t" instead of a
289-
real tab.
290-
291273
==============================================================================
292274
*25.4* Dealing with long lines
293275

@@ -576,6 +558,32 @@ The "gR" command uses Virtual Replace mode. This preserves the layout:
576558

577559
inp 0.786 0.534 0.693 ~
578560

561+
562+
REFORMATTING TABS IN TABLES
563+
564+
You edit a file that contains tabular data and the original author of the file
565+
decided to align the tabular data using tab characters (instead of spaces).
566+
Alas, they were using tab stops separated by 4 columns and Vim's default
567+
is 8 columns; the table looks wrong! What can be done?
568+
To fix the appearance without modifying the file, adjust the setting
569+
temporarily: >
570+
571+
:set tabstop=4
572+
573+
This updates the visual layout, but the file itself remains unchanged.
574+
Another possibility is to permanently reformat the file. For this Vim
575+
provides the |:retab| command. First, set 'tabstop' to match original layout
576+
(as above), then run: >
577+
578+
:retab 8
579+
580+
The ":retab" command will change 'tabstop' to 8, while changing the text such
581+
that it looks the same. It changes spans of white space into tabs and spaces
582+
for this. You can now write the file.
583+
Warning: When using ":retab" on a program, it may change white space inside
584+
a string constant. Therefore it's a good habit to use "\t" instead of a
585+
real tab.
586+
579587
==============================================================================
580588

581589
Next chapter: |usr_26.txt| Repeating

0 commit comments

Comments
 (0)