Skip to content

Update usr_25.{txt,jax} #2105

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
83 changes: 44 additions & 39 deletions doc/usr_25.jax
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
*usr_25.txt* For Vim バージョン 9.1. Last change: 2025 Feb 01
*usr_25.txt* For Vim バージョン 9.1. Last change: 2025 Jun 10

VIM USER MANUAL - by Bram Moolenaar

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

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

the first line ~
the second line ~

Tab キーを押してテキストを挿入、<Enter>、また Tab キーを押してテキストを挿入し
ます。
これは、<Tab>、テキスト、<Enter>、<Tab>、さらにテキストをタイプして入力します。
'autoindent' オプションを設定すると、自動的にインデントできます: >

:set autoindent

新しい行を開始すると、直前の行と同じだけのインデントが挿入されます。上の例な
、<Enter> を押した後の Tab キーが必要なくなります
新しい行を開始すると、直前の行と同じだけのインデントが挿入されます。上記の例で
、<Enter> の後に <Tab> キーを押す必要はなくなりました


☆インデントを増やす

行のインデント量を増やすには ">" オペレータを使います。現在行のインデントを増
やしたい場合は ">>" を使うと簡単です。
行のインデントを増やすには、ノーマルモードで ">" 演算子を使用します。これは多
くの場合、">>" のように使用され、現在の行にインデントを追加します。挿入モード
では <C-t> を使用します。
インデントの増加量は 'shiftwidth' オプションで設定できます。初期設定は 8 です。
例えば、">>" でスペース 4 つ分のインデントを増やしたい場合は次のように設定しま
: >
例えば、">>" でスペース 4 カラム分のインデントを増やしたい場合は次のように設定
します: >

:set shiftwidth=4

Expand All @@ -241,44 +241,25 @@ Tab キーを押してテキストを挿入、<Enter>、また Tab キーを押
"4>>" は四つの行のインデントを増やすコマンドです。


タブストップ
ソフトタブストップ

インデントを 4 桁にしたい場合は 'shiftwidth' を 4 に設定します。しかしそれだけ
では、<Tab> を押したときのインデントの量はスペース 8 個分のままです。これを変
更するには 'softtabstop' オプションを設定します: >
インデントを 4 桁にしたい場合は 'shiftwidth' を 4 に設定します。ただし、<Tab>
キーを押すと、8 カラム分のインデントが保持されます。これを変更するには
'softtabstop' オプションを設定します: >

:set softtabstop=4

これで、<Tab> キーがスペース 4 個分のインデントになります。既に 4 つスペースで
インデントされている場合は <Tab> 文字に置き換えられます (7 バイト節約)。(Tab
文字を使いたくない場合は 'expandtab' を設定してください。)
Vim は 4 カラムごとにカーソルに目に見えないタブストップを作成するようになりま
した。<Tab> を押すと次のストップにジャンプし、必要なスペースまたはタブの正確な
組み合わせが挿入されます。

Note:
'tabstop' オプションを 4 に設定することもできますが、その設定で編集し
たファイルを 'tabstop' の初期設定 (8) で見ると見た目が崩れてしまいま
す。他のプログラムで印刷する場合もインデントが崩れてしまうかもしれませ
ん。したがって、'tabstop' は常に 8 のままにしておきましょう。それが標
準的な値です。


☆TAB幅を変更する
ん。したがって、'tabstop' は常に 8 のままにしておきましょう。UNIX 系シ
ステムの場合、それが標準的な値です。

tabstop が 3 で書かれたファイルを (tabstop が 8 の) Vim で開くと表示が崩れてし
まいます。'tabstop' を 3 に設定すれば表示を直すことができますが、ファイルを開
くたびに設定を変更しなければなりません。
ファイルの tabstop 幅を変更することができます。インデントが正しく表示されるよ
うに 'tabstop' を設定してから ":retab" コマンドを使います: >

:set tabstop=3
:retab 8

":retab" コマンドを使って 'tabstop' を 8 に変更しています。ただし、テキストの
見た目は変更されません。空白部分が Tab 文字とスペースに置き換えられます。その
状態でファイルを保存すれば、次からは設定を変更しなくてもインデントが正しく表示
されます。
警告: プログラムに対して ":retab" を使った場合、文字列定数の中の空白記号が変更
されてしまうかもしれません。文字列定数の中では Tab 文字ではなく "\t" を使うよ
うにしましょう。

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

inp 0.786 0.534 0.693 ~


☆テーブル内のタブを再フォーマットする

表形式のデータを含むファイルを編集しているのですが、ファイルの元の作成者は、表
形式のデータを (スペースではなく) タブ文字で整列させることに決めていました。
なんと、タブ区切りの文字は4列でしたが、Vimのデフォルトは8列です。表の見た目が
おかしくなってしまいます! どうすればいいでしょうか?
ファイルを変更せずに見栄えを修正するには、一時的に設定を調整します: >

:set tabstop=4

これによりレイアウトは更新されますが、ファイル自体は変更されません。
もう 1 つの方法は、ファイルを恒久的に再フォーマットすることです。そのためには、
Vim には |:retab| コマンドが用意されています。まず、'tabstop' を元のレイアウト
に合わせて (上記のように) 設定し、以下を実行します: >

:retab 8

":retab" コマンドを使って 'tabstop' を 8 に変更しています。ただし、テキストの
見た目は変更されません。空白部分が Tab 文字とスペースに置き換えられます。
警告: プログラムに対して ":retab" を使った場合、文字列定数の中の空白記号が変更
されてしまうかもしれません。文字列定数の中では Tab 文字ではなく "\t" を使うよ
うにしましょう。

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

次章: |usr_26.txt| 繰り返し
Expand Down
78 changes: 43 additions & 35 deletions en/usr_25.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
*usr_25.txt* For Vim version 9.1. Last change: 2025 Feb 01
*usr_25.txt* For Vim version 9.1. Last change: 2025 Jun 10

VIM USER MANUAL - by Bram Moolenaar

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

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

This is entered by typing a tab, some text, <Enter>, tab and more text.
This is entered by typing <Tab>, some text, <Enter>, <Tab> and more text.
The 'autoindent' option inserts indents automatically: >

:set autoindent

When a new line is started it gets the same indent as the previous line. In
the above example, the tab after the <Enter> is not needed anymore.
the above example, pressing the <Tab> key after <Enter> is not needed anymore.


INCREASING INDENT

To increase the amount of indent in a line, use the ">" operator. Often this
is used as ">>", which adds indent to the current line.
To increase the amount of indent in a line, use the ">" operator, in Normal
mode. Often this is used as ">>", which adds indent to the current line.
In Insert mode, use <C-t>.
The amount of indent added is specified with the 'shiftwidth' option. The
default value is 8. To make ">>" insert four spaces worth of indent, for
default value is 8. To make ">>" insert four columns worth of indent, for
example, type this: >

:set shiftwidth=4
Expand All @@ -248,46 +249,27 @@ When used on the second line of the example text, this is what you get:
"4>>" will increase the indent of four lines.


TABSTOP
SOFT TAB STOPS

If you want to make indents a multiple of 4, you set 'shiftwidth' to 4. But
when pressing a <Tab> you still get 8 spaces worth of indent. To change this,
set the 'softtabstop' option: >
when pressing a <Tab> you still get 8 columns worth of indent. To change
this, set the 'softtabstop' option: >

:set softtabstop=4

This will make the <Tab> key insert 4 spaces worth of indent. If there are
already four spaces, a <Tab> character is used (saving seven characters in the
file). (If you always want spaces and no tab characters, set the 'expandtab'
option.)
Vim now creates invisible tab stops for your cursor every 4 columns; hitting
<Tab> jumps to the next stop and inserts the exact mix of spaces or tabs
needed.

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


CHANGING TABS

You edit a file which was written with a tabstop of 3. In Vim it looks ugly,
because it uses the normal tabstop value of 8. You can fix this by setting
'tabstop' to 3. But you have to do this every time you edit this file.
Vim can change the use of tabstops in your file. First, set 'tabstop' to
make the indents look good, then use the ":retab" command: >

:set tabstop=3
:retab 8

The ":retab" command will change 'tabstop' to 8, while changing the text such
that it looks the same. It changes spans of white space into tabs and spaces
for this. You can now write the file. Next time you edit it the indents will
be right without setting an option.
Warning: When using ":retab" on a program, it may change white space inside
a string constant. Therefore it's a good habit to use "\t" instead of a
real tab.

==============================================================================
*25.4* Dealing with long lines

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

inp 0.786 0.534 0.693 ~


REFORMATTING TABS IN TABLES

You edit a file that contains tabular data and the original author of the file
decided to align the tabular data using tab characters (instead of spaces).
Alas, they were using tab stops separated by 4 columns and Vim's default
is 8 columns; the table looks wrong! What can be done?
To fix the appearance without modifying the file, adjust the setting
temporarily: >

:set tabstop=4

This updates the visual layout, but the file itself remains unchanged.
Another possibility is to permanently reformat the file. For this Vim
provides the |:retab| command. First, set 'tabstop' to match original layout
(as above), then run: >

:retab 8

The ":retab" command will change 'tabstop' to 8, while changing the text such
that it looks the same. It changes spans of white space into tabs and spaces
for this. You can now write the file.
Warning: When using ":retab" on a program, it may change white space inside
a string constant. Therefore it's a good habit to use "\t" instead of a
real tab.

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

Next chapter: |usr_26.txt| Repeating
Expand Down