annotate runtime/doc/usr_26.txt @ 21062:c2a368193769 v8.2.1082

patch 8.2.1082: Coverity complains about ignoring dict_add() return value Commit: https://github.com/vim/vim/commit/91639195eff7b29213a0a3c279ac46e46ac76edd Author: Bram Moolenaar <Bram@vim.org> Date: Mon Jun 29 19:55:58 2020 +0200 patch 8.2.1082: Coverity complains about ignoring dict_add() return value Problem: Coverity complains about ignoring dict_add() return value. Solution: Add (void).
author Bram Moolenaar <Bram@vim.org>
date Mon, 29 Jun 2020 20:00:04 +0200
parents af69c9335223
children f8116058ca76
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
18879
af69c9335223 Vim 8.2 release
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
1 *usr_26.txt* For Vim version 8.2. Last change: 2006 Apr 24
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3 VIM USER MANUAL - by Bram Moolenaar
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5 Repeating
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8 An editing task is hardly ever unstructured. A change often needs to be made
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9 several times. In this chapter a number of useful ways to repeat a change
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 will be explained.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12 |26.1| Repeating with Visual mode
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13 |26.2| Add and subtract
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 |26.3| Making a change in many files
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15 |26.4| Using Vim from a shell script
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17 Next chapter: |usr_27.txt| Search commands and patterns
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18 Previous chapter: |usr_25.txt| Editing formatted text
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19 Table of contents: |usr_toc.txt|
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21 ==============================================================================
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 *26.1* Repeating with Visual mode
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24 Visual mode is very handy for making a change in any sequence of lines. You
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25 can see the highlighted text, thus you can check if the correct lines are
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26 changed. But making the selection takes some typing. The "gv" command
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27 selects the same area again. This allows you to do another operation on the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28 same text.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29 Suppose you have some lines where you want to change "2001" to "2002" and
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30 "2000" to "2001":
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32 The financial results for 2001 are better ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33 than for 2000. The income increased by 50%, ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34 even though 2001 had more rain than 2000. ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35 2000 2001 ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36 income 45,403 66,234 ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38 First change "2001" to "2002". Select the lines in Visual mode, and use: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
40 :s/2001/2002/g
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
42 Now use "gv" to reselect the same text. It doesn't matter where the cursor
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43 is. Then use ":s/2000/2001/g" to make the second change.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44 Obviously, you can repeat these changes several times.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46 ==============================================================================
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47 *26.2* Add and subtract
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49 When repeating the change of one number into another, you often have a fixed
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
50 offset. In the example above, one was added to each year. Instead of typing
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
51 a substitute command for each year that appears, the CTRL-A command can be
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
52 used.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53 Using the same text as above, search for a year: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
54
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
55 /19[0-9][0-9]\|20[0-9][0-9]
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
57 Now press CTRL-A. The year will be increased by one:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
58
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
59 The financial results for 2002 are better ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
60 than for 2000. The income increased by 50%, ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
61 even though 2001 had more rain than 2000. ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
62 2000 2001 ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
63 income 45,403 66,234 ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
64
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
65 Use "n" to find the next year, and press "." to repeat the CTRL-A ("." is a
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
66 bit quicker to type). Repeat "n" and "." for all years that appear.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
67 Hint: set the 'hlsearch' option to see the matches you are going to change,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
68 then you can look ahead and do it faster.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
69
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
70 Adding more than one can be done by prepending the number to CTRL-A. Suppose
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
71 you have this list:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
72
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
73 1. item four ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
74 2. item five ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
75 3. item six ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
76
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
77 Move the cursor to "1." and type: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
78
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
79 3 CTRL-A
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
81 The "1." will change to "4.". Again, you can use "." to repeat this on the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
82 other numbers.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
83
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
84 Another example:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
85
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
86 006 foo bar ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
87 007 foo bar ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
88
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
89 Using CTRL-A on these numbers results in:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
90
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
91 007 foo bar ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
92 010 foo bar ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
93
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
94 7 plus one is 10? What happened here is that Vim recognized "007" as an octal
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
95 number, because there is a leading zero. This notation is often used in C
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
96 programs. If you do not want a number with leading zeros to be handled as
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
97 octal, use this: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
98
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
99 :set nrformats-=octal
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
100
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
101 The CTRL-X command does subtraction in a similar way.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
102
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
103 ==============================================================================
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
104 *26.3* Making a change in many files
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
105
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
106 Suppose you have a variable called "x_cnt" and you want to change it to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
107 "x_counter". This variable is used in several of your C files. You need to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
108 change it in all files. This is how you do it.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
109 Put all the relevant files in the argument list: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
110
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
111 :args *.c
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
112 <
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
113 This finds all C files and edits the first one. Now you can perform a
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
114 substitution command on all these files: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
115
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
116 :argdo %s/\<x_cnt\>/x_counter/ge | update
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
117
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
118 The ":argdo" command takes an argument that is another command. That command
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
119 will be executed on all files in the argument list.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
120 The "%s" substitute command that follows works on all lines. It finds the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
121 word "x_cnt" with "\<x_cnt\>". The "\<" and "\>" are used to match the whole
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
122 word only, and not "px_cnt" or "x_cnt2".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
123 The flags for the substitute command include "g" to replace all occurrences
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
124 of "x_cnt" in the same line. The "e" flag is used to avoid an error message
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
125 when "x_cnt" does not appear in the file. Otherwise ":argdo" would abort on
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
126 the first file where "x_cnt" was not found.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
127 The "|" separates two commands. The following "update" command writes the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
128 file only if it was changed. If no "x_cnt" was changed to "x_counter" nothing
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
129 happens.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
130
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
131 There is also the ":windo" command, which executes its argument in all
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
132 windows. And ":bufdo" executes its argument on all buffers. Be careful with
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
133 this, because you might have more files in the buffer list than you think.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
134 Check this with the ":buffers" command (or ":ls").
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
135
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
136 ==============================================================================
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
137 *26.4* Using Vim from a shell script
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
138
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
139 Suppose you have a lot of files in which you need to change the string
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
140 "-person-" to "Jones" and then print it. How do you do that? One way is to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
141 do a lot of typing. The other is to write a shell script to do the work.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
142 The Vim editor does a superb job as a screen-oriented editor when using
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
143 Normal mode commands. For batch processing, however, Normal mode commands do
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
144 not result in clear, commented command files; so here you will use Ex mode
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
145 instead. This mode gives you a nice command-line interface that makes it easy
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
146 to put into a batch file. ("Ex command" is just another name for a
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
147 command-line (:) command.)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
148 The Ex mode commands you need are as follows: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
149
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
150 %s/-person-/Jones/g
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
151 write tempfile
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
152 quit
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
153
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
154 You put these commands in the file "change.vim". Now to run the editor in
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
155 batch mode, use this shell script: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
156
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
157 for file in *.txt; do
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
158 vim -e -s $file < change.vim
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
159 lpr -r tempfile
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
160 done
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
161
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
162 The for-done loop is a shell construct to repeat the two lines in between,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
163 while the $file variable is set to a different file name each time.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
164 The second line runs the Vim editor in Ex mode (-e argument) on the file
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
165 $file and reads commands from the file "change.vim". The -s argument tells
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
166 Vim to operate in silent mode. In other words, do not keep outputting the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
167 :prompt, or any other prompt for that matter.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
168 The "lpr -r tempfile" command prints the resulting "tempfile" and deletes
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
169 it (that's what the -r argument does).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
170
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
171
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
172 READING FROM STDIN
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
173
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
174 Vim can read text on standard input. Since the normal way is to read commands
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
175 there, you must tell Vim to read text instead. This is done by passing the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
176 "-" argument in place of a file. Example: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
177
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
178 ls | vim -
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
179
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
180 This allows you to edit the output of the "ls" command, without first saving
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
181 the text in a file.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
182 If you use the standard input to read text from, you can use the "-S"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
183 argument to read a script: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
184
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
185 producer | vim -S change.vim -
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
186
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
187
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
188 NORMAL MODE SCRIPTS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
189
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
190 If you really want to use Normal mode commands in a script, you can use it
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
191 like this: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
192
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
193 vim -s script file.txt ...
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
194 <
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
195 Note:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
196 "-s" has a different meaning when it is used without "-e". Here it
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
197 means to source the "script" as Normal mode commands. When used with
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
198 "-e" it means to be silent, and doesn't use the next argument as a
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
199 file name.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
200
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
201 The commands in "script" are executed like you typed them. Don't forget that
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
202 a line break is interpreted as pressing <Enter>. In Normal mode that moves
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
203 the cursor to the next line.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
204 To create the script you can edit the script file and type the commands.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
205 You need to imagine what the result would be, which can be a bit difficult.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
206 Another way is to record the commands while you perform them manually. This
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
207 is how you do that: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
208
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
209 vim -w script file.txt ...
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
210
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
211 All typed keys will be written to "script". If you make a small mistake you
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
212 can just continue and remember to edit the script later.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
213 The "-w" argument appends to an existing script. That is good when you
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
214 want to record the script bit by bit. If you want to start from scratch and
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
215 start all over, use the "-W" argument. It overwrites any existing file.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
216
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
217 ==============================================================================
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
218
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
219 Next chapter: |usr_27.txt| Search commands and patterns
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
220
14519
5c5908e81e93 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13963
diff changeset
221 Copyright: see |manual-copyright| vim:tw=78:ts=8:noet:ft=help:norl: