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
217217Indents 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
220220text:
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
233233INCREASING 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
239240example, 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
253254If 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
581589Next chapter: | usr_26.txt | Repeating
0 commit comments