annotate runtime/doc/usr_23.txt @ 26877:06a137af96f8 v8.2.3967

patch 8.2.3967: error messages are spread out Commit: https://github.com/vim/vim/commit/460ae5dfca31fa627531c263184849976755cf6b Author: Bram Moolenaar <Bram@vim.org> Date: Sat Jan 1 14:19:49 2022 +0000 patch 8.2.3967: error messages are spread out Problem: Error messages are spread out. Solution: Move more errors to errors.h.
author Bram Moolenaar <Bram@vim.org>
date Sat, 01 Jan 2022 15:30:05 +0100
parents fab58304f77d
children f8116058ca76
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
23305
fab58304f77d Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 18972
diff changeset
1 *usr_23.txt* For Vim version 8.2. Last change: 2020 Dec 19
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 Editing other files
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 This chapter is about editing files that are not ordinary files. With Vim you
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9 can edit files that are compressed or encrypted. Some files need to be
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 accessed over the internet. With some restrictions, binary files can be
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11 edited as well.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13 |23.1| DOS, Mac and Unix files
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 |23.2| Files on the internet
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15 |23.3| Encryption
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16 |23.4| Binary files
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17 |23.5| Compressed files
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19 Next chapter: |usr_24.txt| Inserting quickly
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20 Previous chapter: |usr_22.txt| Finding the file to edit
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21 Table of contents: |usr_toc.txt|
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23 ==============================================================================
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24 *23.1* DOS, Mac and Unix files
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26 Back in the early days, the old Teletype machines used two characters to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27 start a new line. One to move the carriage back to the first position
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28 (carriage return, <CR>), another to move the paper up (line feed, <LF>).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29 When computers came out, storage was expensive. Some people decided that
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30 they did not need two characters for end-of-line. The UNIX people decided
23305
fab58304f77d Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 18972
diff changeset
31 they could use <New Line> or <NL> only for end-of-line. The Apple people
fab58304f77d Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 18972
diff changeset
32 standardized on <CR>. The Microsoft Windows folks decided to keep the old
fab58304f77d Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 18972
diff changeset
33 <CR><NL> (we use <NL> for line feed in the help text).
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34 This means that if you try to move a file from one system to another, you
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35 have line-break problems. The Vim editor automatically recognizes the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36 different file formats and handles things properly behind your back.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37 The option 'fileformats' contains the various formats that will be tried
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38 when a new file is edited. The following command, for example, tells Vim to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39 try UNIX format first and MS-DOS format second: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
40
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41 :set fileformats=unix,dos
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
42
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43 You will notice the format in the message you get when editing a file. You
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44 don't see anything if you edit a native file format. Thus editing a Unix file
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45 on Unix won't result in a remark. But when you edit a dos file, Vim will
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46 notify you of this:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48 "/tmp/test" [dos] 3L, 71C ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
50 For a Mac file you would see "[mac]".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
51 The detected file format is stored in the 'fileformat' option. To see
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
52 which format you have, execute the following command: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
54 :set fileformat?
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
55
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56 The three names that Vim uses are:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
57
23305
fab58304f77d Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 18972
diff changeset
58 unix <NL>
fab58304f77d Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 18972
diff changeset
59 dos <CR><NL>
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
60 mac <CR>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
61
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
62
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
63 USING THE MAC FORMAT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
64
23305
fab58304f77d Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 18972
diff changeset
65 On Unix, <NL> is used to break a line. It's not unusual to have a <CR>
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
66 character halfway a line. Incidentally, this happens quite often in Vi (and
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
67 Vim) scripts.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
68 On the Macintosh, where <CR> is the line break character, it's possible to
23305
fab58304f77d Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 18972
diff changeset
69 have a <NL> character halfway a line.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
70 The result is that it's not possible to be 100% sure whether a file
23305
fab58304f77d Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 18972
diff changeset
71 containing both <CR> and <NL> characters is a Mac or a Unix file. Therefore,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
72 Vim assumes that on Unix you probably won't edit a Mac file, and doesn't check
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
73 for this type of file. To check for this format anyway, add "mac" to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
74 'fileformats': >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
75
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
76 :set fileformats+=mac
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
77
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
78 Then Vim will take a guess at the file format. Watch out for situations where
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
79 Vim guesses wrong.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
81
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
82 OVERRULING THE FORMAT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
83
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
84 If you use the good old Vi and try to edit an MS-DOS format file, you will
237
73354c21f1e4 updated for version 7.0066
vimboss
parents: 7
diff changeset
85 find that each line ends with a ^M character. (^M is <CR>). The automatic
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
86 detection avoids this. Suppose you do want to edit the file that way? Then
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
87 you need to overrule the format: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
88
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
89 :edit ++ff=unix file.txt
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
90
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
91 The "++" string is an item that tells Vim that an option name follows, which
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
92 overrules the default for this single command. "++ff" is used for
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
93 'fileformat'. You could also use "++ff=mac" or "++ff=dos".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
94 This doesn't work for any option, only "++ff" and "++enc" are currently
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
95 implemented. The full names "++fileformat" and "++encoding" also work.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
96
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
97
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
98 CONVERSION
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
99
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
100 You can use the 'fileformat' option to convert from one file format to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
101 another. Suppose, for example, that you have an MS-DOS file named README.TXT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
102 that you want to convert to UNIX format. Start by editing the MS-DOS format
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
103 file: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
104 vim README.TXT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
105
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
106 Vim will recognize this as a dos format file. Now change the file format to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
107 UNIX: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
108
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
109 :set fileformat=unix
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
110 :write
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
111
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
112 The file is written in Unix format.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
113
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
114 ==============================================================================
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
115 *23.2* Files on the internet
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
116
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
117 Someone sends you an e-mail message, which refers to a file by its URL. For
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
118 example:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
119
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
120 You can find the information here: ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
121 ftp://ftp.vim.org/pub/vim/README ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
122
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
123 You could start a program to download the file, save it on your local disk and
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
124 then start Vim to edit it.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
125 There is a much simpler way. Move the cursor to any character of the URL.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
126 Then use this command: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
127
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
128 gf
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
129
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
130 With a bit of luck, Vim will figure out which program to use for downloading
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
131 the file, download it and edit the copy. To open the file in a new window use
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
132 CTRL-W f.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
133 If something goes wrong you will get an error message. It's possible that
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
134 the URL is wrong, you don't have permission to read it, the network connection
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
135 is down, etc. Unfortunately, it's hard to tell the cause of the error. You
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
136 might want to try the manual way of downloading the file.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
137
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
138 Accessing files over the internet works with the netrw plugin. Currently URLs
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
139 with these formats are recognized:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
140
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
141 ftp:// uses ftp
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
142 rcp:// uses rcp
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
143 scp:// uses scp
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
144 http:// uses wget (reading only)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
145
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
146 Vim doesn't do the communication itself, it relies on the mentioned programs
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
147 to be available on your computer. On most Unix systems "ftp" and "rcp" will
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
148 be present. "scp" and "wget" might need to be installed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
149
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
150 Vim detects these URLs for each command that starts editing a new file, also
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
151 with ":edit" and ":split", for example. Write commands also work, except for
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
152 http://.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
153
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
154 For more information, also about passwords, see |netrw|.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
155
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
156 ==============================================================================
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
157 *23.3* Encryption
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
158
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
159 Some information you prefer to keep to yourself. For example, when writing
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
160 a test on a computer that students also use. You don't want clever students
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
161 to figure out a way to read the questions before the exam starts. Vim can
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
162 encrypt the file for you, which gives you some protection.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
163 To start editing a new file with encryption, use the "-x" argument to start
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
164 Vim. Example: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
165
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
166 vim -x exam.txt
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
167
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
168 Vim prompts you for a key used for encrypting and decrypting the file:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
169
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
170 Enter encryption key: ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
171
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
172 Carefully type the secret key now. You cannot see the characters you type,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
173 they will be replaced by stars. To avoid the situation that a typing mistake
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
174 will cause trouble, Vim asks you to enter the key again:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
175
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
176 Enter same key again: ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
177
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
178 You can now edit this file normally and put in all your secrets. When you
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
179 finish editing the file and tell Vim to exit, the file is encrypted and
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
180 written.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
181 When you edit the file with Vim, it will ask you to enter the same key
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
182 again. You don't need to use the "-x" argument. You can also use the normal
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
183 ":edit" command. Vim adds a magic string to the file by which it recognizes
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
184 that the file was encrypted.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
185 If you try to view this file using another program, all you get is garbage.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
186 Also, if you edit the file with Vim and enter the wrong key, you get garbage.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
187 Vim does not have a mechanism to check if the key is the right one (this makes
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
188 it much harder to break the key).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
189
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
190
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
191 SWITCHING ENCRYPTION ON AND OFF
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
192
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
193 To disable the encryption of a file, set the 'key' option to an empty string:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
194 >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
195 :set key=
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
196
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
197 The next time you write the file this will be done without encryption.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
198 Setting the 'key' option to enable encryption is not a good idea, because
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
199 the password appears in the clear. Anyone shoulder-surfing can read your
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
200 password.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
201 To avoid this problem, the ":X" command was created. It asks you for an
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
202 encryption key, just like the "-x" argument did: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
203
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
204 :X
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
205 Enter encryption key: ******
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
206 Enter same key again: ******
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
207
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
208
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
209 LIMITS ON ENCRYPTION
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
210
14999
2b30a2b4bde2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
211 The encryption algorithm used by Vim is not very strong. It is good enough to
2b30a2b4bde2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
212 keep out the casual prowler, but not good enough to keep out a cryptology
2b30a2b4bde2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
213 expert with lots of time on his hands. The text in the swap file and the undo
2b30a2b4bde2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
214 file is also encrypted. However, this is done block-by-block and may reduce
2b30a2b4bde2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
215 the time needed to crack a password. You can disable the swap file, but then
2b30a2b4bde2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
216 a crash will cause you to lose your work, since Vim keeps all the text in
2b30a2b4bde2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
217 memory only. The undo file can be disabled with the only disadvantage that
2b30a2b4bde2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
218 you can't undo after unloading the buffer.
2b30a2b4bde2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
219 To avoid using a swap file, supply the -n argument on the command line.
2b30a2b4bde2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
220 For example, to edit the encrypted file "file.txt" without a swap file use the
2b30a2b4bde2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
221 following command: >
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
222
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
223 vim -x -n file.txt
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
224
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
225 When already editing a file, the swapfile can be disabled with: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
226
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
227 :setlocal noswapfile
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
228
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
229 Since there is no swapfile, recovery will be impossible. Save the file a bit
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
230 more often to avoid the risk of losing your changes.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
231
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
232 While the file is in memory, it is in plain text. Anyone with privilege can
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
233 look in the editor's memory and discover the contents of the file.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
234 If you use a viminfo file, be aware that the contents of text registers are
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
235 written out in the clear as well.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
236 If you really want to secure the contents of a file, edit it only on a
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
237 portable computer not connected to a network, use good encryption tools, and
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
238 keep the computer locked up in a big safe when not in use.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
239
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
240 ==============================================================================
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
241 *23.4* Binary files
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
242
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
243 You can edit binary files with Vim. Vim wasn't really made for this, thus
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
244 there are a few restrictions. But you can read a file, change a character and
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
245 write it back, with the result that only that one character was changed and
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
246 the file is identical otherwise.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
247 To make sure that Vim does not use its clever tricks in the wrong way, add
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
248 the "-b" argument when starting Vim: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
249
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
250 vim -b datafile
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
251
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
252 This sets the 'binary' option. The effect of this is that unexpected side
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
253 effects are turned off. For example, 'textwidth' is set to zero, to avoid
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
254 automatic formatting of lines. And files are always read in Unix file format.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
255
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
256 Binary mode can be used to change a message in a program. Be careful not to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
257 insert or delete any characters, it would stop the program from working. Use
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
258 "R" to enter replace mode.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
259
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
260 Many characters in the file will be unprintable. To see them in Hex format: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
261
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
262 :set display=uhex
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
263
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
264 Otherwise, the "ga" command can be used to see the value of the character
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
265 under the cursor. The output, when the cursor is on an <Esc>, looks like
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
266 this:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
267
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
268 <^[> 27, Hex 1b, Octal 033 ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
269
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
270 There might not be many line breaks in the file. To get some overview switch
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
271 the 'wrap' option off: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
272
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
273 :set nowrap
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
274
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
275
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
276 BYTE POSITION
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
277
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
278 To see on which byte you are in the file use this command: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
279
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
280 g CTRL-G
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
281
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
282 The output is verbose:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
283
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
284 Col 9-16 of 9-16; Line 277 of 330; Word 1806 of 2058; Byte 10580 of 12206 ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
285
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
286 The last two numbers are the byte position in the file and the total number of
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
287 bytes. This takes into account how 'fileformat' changes the number of bytes
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
288 that a line break uses.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
289 To move to a specific byte in the file, use the "go" command. For
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
290 example, to move to byte 2345: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
291
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
292 2345go
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
293
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
294
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
295 USING XXD
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
296
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
297 A real binary editor shows the text in two ways: as it is and in hex format.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
298 You can do this in Vim by first converting the file with the "xxd" program.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
299 This comes with Vim.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
300 First edit the file in binary mode: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
301
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
302 vim -b datafile
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
303
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
304 Now convert the file to a hex dump with xxd: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
305
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
306 :%!xxd
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
307
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
308 The text will look like this:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
309
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
310 0000000: 1f8b 0808 39d7 173b 0203 7474 002b 4e49 ....9..;..tt.+NI ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
311 0000010: 4b2c 8660 eb9c ecac c462 eb94 345e 2e30 K,.`.....b..4^.0 ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
312 0000020: 373b 2731 0b22 0ca6 c1a2 d669 1035 39d9 7;'1.".....i.59. ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
313
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
314 You can now view and edit the text as you like. Vim treats the information as
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
315 ordinary text. Changing the hex does not cause the printable character to be
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
316 changed, or the other way around.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
317 Finally convert it back with:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
318 >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
319 :%!xxd -r
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
320
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
321 Only changes in the hex part are used. Changes in the printable text part on
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
322 the right are ignored.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
323
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
324 See the manual page of xxd for more information.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
325
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
326 ==============================================================================
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
327 *23.5* Compressed files
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
328
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
329 This is easy: You can edit a compressed file just like any other file. The
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
330 "gzip" plugin takes care of decompressing the file when you edit it. And
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
331 compressing it again when you write it.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
332 These compression methods are currently supported:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
333
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
334 .Z compress
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
335 .gz gzip
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
336 .bz2 bzip2
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
337
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
338 Vim uses the mentioned programs to do the actual compression and
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
339 decompression. You might need to install the programs first.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
340
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
341 ==============================================================================
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
342
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
343 Next chapter: |usr_24.txt| Inserting quickly
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
344
14519
5c5908e81e93 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13963
diff changeset
345 Copyright: see |manual-copyright| vim:tw=78:ts=8:noet:ft=help:norl: