annotate runtime/doc/usr_11.txt @ 17854:9cd094b68fa5

Added tag v8.1.1923 for changeset c90ca5b9fc0dccb5845505f442b5adc42e62b480
author Bram Moolenaar <Bram@vim.org>
date Sat, 24 Aug 2019 22:00:04 +0200
parents 4e9bea9b8025
children af69c9335223
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
16453
4e9bea9b8025 patch 8.1.1231: asking about existing swap file unnecessarily
Bram Moolenaar <Bram@vim.org>
parents: 15878
diff changeset
1 *usr_11.txt* For Vim version 8.1. Last change: 2019 Apr 28
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 Recovering from a crash
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 Did your computer crash? And you just spent hours editing? Don't panic! Vim
2033
de5a43c5eedc Update documentation files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
9 stores enough information to be able to restore most of your work. This
de5a43c5eedc Update documentation files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
10 chapter shows you how to get your work back and explains how the swap file is
de5a43c5eedc Update documentation files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
11 used.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13 |11.1| Basic recovery
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 |11.2| Where is the swap file?
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15 |11.3| Crashed or not?
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16 |11.4| Further reading
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18 Next chapter: |usr_12.txt| Clever tricks
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19 Previous chapter: |usr_10.txt| Making big changes
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20 Table of contents: |usr_toc.txt|
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 ==============================================================================
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23 *11.1* Basic recovery
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25 In most cases recovering a file is quite simple, assuming you know which file
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26 you were editing (and the harddisk is still working). Start Vim on the file,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27 with the "-r" argument added: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29 vim -r help.txt
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31 Vim will read the swap file (used to store text you were editing) and may read
2162
0527eb0f6918 After recovery check if the text changed. If it did mark the buffer as
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
32 bits and pieces of the original file. If Vim recovered your changes you will
0527eb0f6918 After recovery check if the text changed. If it did mark the buffer as
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
33 see these messages (with different file names, of course):
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35 Using swap file ".help.txt.swp" ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36 Original file "~/vim/runtime/doc/help.txt" ~
323
03b3684919e3 updated for version 7.0084
vimboss
parents: 237
diff changeset
37 Recovery completed. You should check if everything is OK. ~
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38 (You might want to write out this file under another name ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39 and run diff with the original file to check for changes) ~
2162
0527eb0f6918 After recovery check if the text changed. If it did mark the buffer as
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
40 You may want to delete the .swp file now. ~
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
42 To be on the safe side, write this file under another name: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44 :write help.txt.recovered
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46 Compare the file with the original file to check if you ended up with what you
2162
0527eb0f6918 After recovery check if the text changed. If it did mark the buffer as
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
47 expected. Vimdiff is very useful for this |08.7|. For example: >
0527eb0f6918 After recovery check if the text changed. If it did mark the buffer as
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
48
0527eb0f6918 After recovery check if the text changed. If it did mark the buffer as
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
49 :write help.txt.recovered
0527eb0f6918 After recovery check if the text changed. If it did mark the buffer as
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
50 :edit #
0527eb0f6918 After recovery check if the text changed. If it did mark the buffer as
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
51 :diffsp help.txt
0527eb0f6918 After recovery check if the text changed. If it did mark the buffer as
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
52
0527eb0f6918 After recovery check if the text changed. If it did mark the buffer as
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
53 Watch out for the original file to contain a more recent version (you saved
0527eb0f6918 After recovery check if the text changed. If it did mark the buffer as
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
54 the file just before the computer crashed). And check that no lines are
0527eb0f6918 After recovery check if the text changed. If it did mark the buffer as
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
55 missing (something went wrong that Vim could not recover).
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56 If Vim produces warning messages when recovering, read them carefully.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
57 This is rare though.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
58
2162
0527eb0f6918 After recovery check if the text changed. If it did mark the buffer as
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
59 If the recovery resulted in text that is exactly the same as the file
0527eb0f6918 After recovery check if the text changed. If it did mark the buffer as
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
60 contents, you will get this message:
0527eb0f6918 After recovery check if the text changed. If it did mark the buffer as
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
61
0527eb0f6918 After recovery check if the text changed. If it did mark the buffer as
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
62 Using swap file ".help.txt.swp" ~
0527eb0f6918 After recovery check if the text changed. If it did mark the buffer as
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
63 Original file "~/vim/runtime/doc/help.txt" ~
0527eb0f6918 After recovery check if the text changed. If it did mark the buffer as
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
64 Recovery completed. Buffer contents equals file contents. ~
0527eb0f6918 After recovery check if the text changed. If it did mark the buffer as
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
65 You may want to delete the .swp file now. ~
0527eb0f6918 After recovery check if the text changed. If it did mark the buffer as
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
66
0527eb0f6918 After recovery check if the text changed. If it did mark the buffer as
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
67 This usually happens if you already recovered your changes, or you wrote the
0527eb0f6918 After recovery check if the text changed. If it did mark the buffer as
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
68 file after making changes. It is safe to delete the swap file now.
0527eb0f6918 After recovery check if the text changed. If it did mark the buffer as
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
69
0527eb0f6918 After recovery check if the text changed. If it did mark the buffer as
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
70 It is normal that the last few changes can not be recovered. Vim flushes the
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
71 changes to disk when you don't type for about four seconds, or after typing
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
72 about two hundred characters. This is set with the 'updatetime' and
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
73 'updatecount' options. Thus when Vim didn't get a chance to save itself when
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
74 the system went down, the changes after the last flush will be lost.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
75
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
76 If you were editing without a file name, give an empty string as argument: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
77
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
78 vim -r ""
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
79
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80 You must be in the right directory, otherwise Vim can't find the swap file.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
81
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
82 ==============================================================================
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
83 *11.2* Where is the swap file?
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
84
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
85 Vim can store the swap file in several places. Normally it is in the same
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
86 directory as the original file. To find it, change to the directory of the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
87 file, and use: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
88
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
89 vim -r
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
90
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
91 Vim will list the swap files that it can find. It will also look in other
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
92 directories where the swap file for files in the current directory may be
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
93 located. It will not find swap files in any other directories though, it
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
94 doesn't search the directory tree.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
95 The output could look like this:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
96
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
97 Swap files found: ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
98 In current directory: ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
99 1. .main.c.swp ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
100 owned by: mool dated: Tue May 29 21:00:25 2001 ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
101 file name: ~mool/vim/vim6/src/main.c ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
102 modified: YES ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
103 user name: mool host name: masaka.moolenaar.net ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
104 process ID: 12525 ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
105 In directory ~/tmp: ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
106 -- none -- ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
107 In directory /var/tmp: ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
108 -- none -- ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
109 In directory /tmp: ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
110 -- none -- ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
111
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
112 If there are several swap files that look like they may be the one you want to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
113 use, a list is given of these swap files and you are requested to enter the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
114 number of the one you want to use. Carefully look at the dates to decide
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
115 which one you want to use.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
116 In case you don't know which one to use, just try them one by one and check
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
117 the resulting files if they are what you expected.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
118
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
119
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
120 USING A SPECIFIC SWAP FILE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
121
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
122 If you know which swap file needs to be used, you can recover by giving the
15729
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14637
diff changeset
123 swap file name. Vim will then find out the name of the original file from
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
124 the swap file.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
125
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
126 Example: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
127 vim -r .help.txt.swo
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
128
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
129 This is also handy when the swap file is in another directory than expected.
2033
de5a43c5eedc Update documentation files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
130 Vim recognizes files with the pattern *.s[uvw][a-z] as swap files.
de5a43c5eedc Update documentation files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
131
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
132 If this still does not work, see what file names Vim reports and rename the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
133 files accordingly. Check the 'directory' option to see where Vim may have
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
134 put the swap file.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
135
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
136 Note:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
137 Vim tries to find the swap file by searching the directories in the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
138 'dir' option, looking for files that match "filename.sw?". If
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
139 wildcard expansion doesn't work (e.g., when the 'shell' option is
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
140 invalid), Vim does a desperate try to find the file "filename.swp".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
141 If that fails too, you will have to give the name of the swapfile
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
142 itself to be able to recover the file.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
143
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
144 ==============================================================================
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
145 *11.3* Crashed or not? *ATTENTION* *E325*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
146
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
147 Vim tries to protect you from doing stupid things. Suppose you innocently
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
148 start editing a file, expecting the contents of the file to show up. Instead,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
149 Vim produces a very long message:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
150
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
151 E325: ATTENTION ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
152 Found a swap file by the name ".main.c.swp" ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
153 owned by: mool dated: Tue May 29 21:09:28 2001 ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
154 file name: ~mool/vim/vim6/src/main.c ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
155 modified: no ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
156 user name: mool host name: masaka.moolenaar.net ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
157 process ID: 12559 (still running) ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
158 While opening file "main.c" ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
159 dated: Tue May 29 19:46:12 2001 ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
160 ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
161 (1) Another program may be editing the same file. ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
162 If this is the case, be careful not to end up with two ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
163 different instances of the same file when making changes. ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
164 Quit, or continue with caution. ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
165 ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
166 (2) An edit session for this file crashed. ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
167 If this is the case, use ":recover" or "vim -r main.c" ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
168 to recover the changes (see ":help recovery"). ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
169 If you did this already, delete the swap file ".main.c.swp" ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
170 to avoid this message. ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
171
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
172 You get this message, because, when starting to edit a file, Vim checks if a
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
173 swap file already exists for that file. If there is one, there must be
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
174 something wrong. It may be one of these two situations.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
175
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
176 1. Another edit session is active on this file. Look in the message for the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
177 line with "process ID". It might look like this:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
178
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
179 process ID: 12559 (still running) ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
180
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
181 The text "(still running)" indicates that the process editing this file
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
182 runs on the same computer. When working on a non-Unix system you will not
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
183 get this extra hint. When editing a file over a network, you may not see
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
184 the hint, because the process might be running on another computer. In
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
185 those two cases you must find out what the situation is yourself.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
186 If there is another Vim editing the same file, continuing to edit will
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
187 result in two versions of the same file. The one that is written last will
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
188 overwrite the other one, resulting in loss of changes. You better quit
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
189 this Vim.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
190
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
191 2. The swap file might be the result from a previous crash of Vim or the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
192 computer. Check the dates mentioned in the message. If the date of the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
193 swap file is newer than the file you were editing, and this line appears:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
194
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
195 modified: YES ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
196
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
197 Then you very likely have a crashed edit session that is worth recovering.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
198 If the date of the file is newer than the date of the swap file, then
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
199 either it was changed after the crash (perhaps you recovered it earlier,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
200 but didn't delete the swap file?), or else the file was saved before the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
201 crash but after the last write of the swap file (then you're lucky: you
237
73354c21f1e4 updated for version 7.0066
vimboss
parents: 7
diff changeset
202 don't even need that old swap file). Vim will warn you for this with this
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
203 extra line:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
204
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
205 NEWER than swap file! ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
206
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
207
16453
4e9bea9b8025 patch 8.1.1231: asking about existing swap file unnecessarily
Bram Moolenaar <Bram@vim.org>
parents: 15878
diff changeset
208 NOTE that in the following situation Vim knows the swap file is not useful and
4e9bea9b8025 patch 8.1.1231: asking about existing swap file unnecessarily
Bram Moolenaar <Bram@vim.org>
parents: 15878
diff changeset
209 will automatically delete it:
4e9bea9b8025 patch 8.1.1231: asking about existing swap file unnecessarily
Bram Moolenaar <Bram@vim.org>
parents: 15878
diff changeset
210 - The file is a valid swap file (Magic number is correct).
4e9bea9b8025 patch 8.1.1231: asking about existing swap file unnecessarily
Bram Moolenaar <Bram@vim.org>
parents: 15878
diff changeset
211 - The flag that the file was modified is not set.
4e9bea9b8025 patch 8.1.1231: asking about existing swap file unnecessarily
Bram Moolenaar <Bram@vim.org>
parents: 15878
diff changeset
212 - The process is not running.
4e9bea9b8025 patch 8.1.1231: asking about existing swap file unnecessarily
Bram Moolenaar <Bram@vim.org>
parents: 15878
diff changeset
213
4e9bea9b8025 patch 8.1.1231: asking about existing swap file unnecessarily
Bram Moolenaar <Bram@vim.org>
parents: 15878
diff changeset
214
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
215 UNREADABLE SWAP FILE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
216
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
217 Sometimes the line
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
218
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
219 [cannot be read] ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
220
237
73354c21f1e4 updated for version 7.0066
vimboss
parents: 7
diff changeset
221 will appear under the name of the swap file. This can be good or bad,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
222 depending on circumstances.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
223
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
224 It is good if a previous editing session crashed without having made any
237
73354c21f1e4 updated for version 7.0066
vimboss
parents: 7
diff changeset
225 changes to the file. Then a directory listing of the swap file will show
73354c21f1e4 updated for version 7.0066
vimboss
parents: 7
diff changeset
226 that it has zero bytes. You may delete it and proceed.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
227
237
73354c21f1e4 updated for version 7.0066
vimboss
parents: 7
diff changeset
228 It is slightly bad if you don't have read permission for the swap file. You
73354c21f1e4 updated for version 7.0066
vimboss
parents: 7
diff changeset
229 may want to view the file read-only, or quit. On multi-user systems, if you
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
230 yourself did the last changes under a different login name, a logout
237
73354c21f1e4 updated for version 7.0066
vimboss
parents: 7
diff changeset
231 followed by a login under that other name might cure the "read error". Or
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
232 else you might want to find out who last edited (or is editing) the file and
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
233 have a talk with them.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
234
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
235 It is very bad if it means there is a physical read error on the disk
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
236 containing the swap file. Fortunately, this almost never happens.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
237 You may want to view the file read-only at first (if you can), to see the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
238 extent of the changes that were "forgotten". If you are the one in charge of
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
239 that file, be prepared to redo your last changes.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
240
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
241
2033
de5a43c5eedc Update documentation files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
242 WHAT TO DO? *swap-exists-choices*
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
243
13735
a62eeee5f116 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 10198
diff changeset
244 If dialogs are supported you will be asked to select one of six choices:
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
245
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
246 Swap file ".main.c.swp" already exists! ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
247 [O]pen Read-Only, (E)dit anyway, (R)ecover, (Q)uit, (A)bort, (D)elete it: ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
248
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
249 O Open the file readonly. Use this when you just want to view the file and
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
250 don't need to recover it. You might want to use this when you know someone
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
251 else is editing the file, but you just want to look in it and not make
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
252 changes.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
253
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
254 E Edit the file anyway. Use this with caution! If the file is being edited
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
255 in another Vim, you might end up with two versions of the file. Vim will
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
256 try to warn you when this happens, but better be safe then sorry.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
257
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
258 R Recover the file from the swap file. Use this if you know that the swap
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
259 file contains changes that you want to recover.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
260
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
261 Q Quit. This avoids starting to edit the file. Use this if there is another
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
262 Vim editing the same file.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
263 When you just started Vim, this will exit Vim. When starting Vim with
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
264 files in several windows, Vim quits only if there is a swap file for the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
265 first one. When using an edit command, the file will not be loaded and you
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
266 are taken back to the previously edited file.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
267
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
268 A Abort. Like Quit, but also abort further commands. This is useful when
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
269 loading a script that edits several files, such as a session with multiple
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
270 windows.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
271
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
272 D Delete the swap file. Use this when you are sure you no longer need it.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
273 For example, when it doesn't contain changes, or when the file itself is
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
274 newer than the swap file.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
275 On Unix this choice is only offered when the process that created the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
276 swap file does not appear to be running.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
277
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
278 If you do not get the dialog (you are running a version of Vim that does not
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
279 support it), you will have to do it manually. To recover the file, use this
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
280 command: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
281
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
282 :recover
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
283
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
284
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
285 Vim cannot always detect that a swap file already exists for a file. This is
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
286 the case when the other edit session puts the swap files in another directory
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
287 or when the path name for the file is different when editing it on different
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
288 machines. Therefore, don't rely on Vim always warning you.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
289
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
290 If you really don't want to see this message, you can add the 'A' flag to the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
291 'shortmess' option. But it's very unusual that you need this.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
292
2267
c08f91142c41 Crypt the swapfile.
Bram Moolenaar <bram@vim.org>
parents: 2162
diff changeset
293 For remarks about encryption and the swap file, see |:recover-crypt|.
15878
314694a2e74a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 15729
diff changeset
294 For programatic access to the swap file, see |swapinfo()|.
2267
c08f91142c41 Crypt the swapfile.
Bram Moolenaar <bram@vim.org>
parents: 2162
diff changeset
295
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
296 ==============================================================================
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
297 *11.4* Further reading
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
298
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
299 |swap-file| An explanation about where the swap file will be created and
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
300 what its name is.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
301 |:preserve| Manually flushing the swap file to disk.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
302 |:swapname| See the name of the swap file for the current file.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
303 'updatecount' Number of key strokes after which the swap file is flushed to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
304 disk.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
305 'updatetime' Timeout after which the swap file is flushed to disk.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
306 'swapsync' Whether the disk is synced when the swap file is flushed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
307 'directory' List of directory names where to store the swap file.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
308 'maxmem' Limit for memory usage before writing text to the swap file.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
309 'maxmemtot' Same, but for all files in total.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
310
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
311 ==============================================================================
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
312
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
313 Next chapter: |usr_12.txt| Clever tricks
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
314
14519
5c5908e81e93 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13963
diff changeset
315 Copyright: see |manual-copyright| vim:tw=78:ts=8:noet:ft=help:norl: