Mercurial > vim
comparison runtime/doc/autocmd.txt @ 27162:b19230a8d40a
Update runtime files
Commit: https://github.com/vim/vim/commit/fd31be29b8220ee1cb0b3460c82f2634ae3cc370
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Jan 16 14:46:06 2022 +0000
Update runtime files
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 16 Jan 2022 16:00:06 +0100 |
parents | 3c1dcb63f579 |
children | 3649b5a6b1b6 |
comparison
equal
deleted
inserted
replaced
27161:4ed1558cabe1 | 27162:b19230a8d40a |
---|---|
1 *autocmd.txt* For Vim version 8.2. Last change: 2021 Nov 20 | 1 *autocmd.txt* For Vim version 8.2. Last change: 2022 Jan 15 |
2 | 2 |
3 | 3 |
4 VIM REFERENCE MANUAL by Bram Moolenaar | 4 VIM REFERENCE MANUAL by Bram Moolenaar |
5 | 5 |
6 | 6 |
49 | 49 |
50 ============================================================================== | 50 ============================================================================== |
51 2. Defining autocommands *autocmd-define* | 51 2. Defining autocommands *autocmd-define* |
52 | 52 |
53 *:au* *:autocmd* | 53 *:au* *:autocmd* |
54 :au[tocmd] [group] {event} {pat} [++once] [++nested] {cmd} | 54 :au[tocmd] [group] {event} {aupat} [++once] [++nested] {cmd} |
55 Add {cmd} to the list of commands that Vim will | 55 Add {cmd} to the list of commands that Vim will |
56 execute automatically on {event} for a file matching | 56 execute automatically on {event} for a file matching |
57 {pat} |autocmd-patterns|. | 57 {aupat} |autocmd-patterns|. |
58 Here {event} cannot be "*". *E1155* | 58 Here {event} cannot be "*". *E1155* |
59 Note: A quote character is seen as argument to the | 59 Note: A quote character is seen as argument to the |
60 :autocmd and won't start a comment. | 60 :autocmd and won't start a comment. |
61 Vim always adds the {cmd} after existing autocommands, | 61 Vim always adds the {cmd} after existing autocommands, |
62 so that the autocommands execute in the order in which | 62 so that the autocommands execute in the order in which |
143 prompt. When one command outputs two messages this can happen anyway. | 143 prompt. When one command outputs two messages this can happen anyway. |
144 | 144 |
145 ============================================================================== | 145 ============================================================================== |
146 3. Removing autocommands *autocmd-remove* | 146 3. Removing autocommands *autocmd-remove* |
147 | 147 |
148 :au[tocmd]! [group] {event} {pat} [++once] [++nested] {cmd} | 148 :au[tocmd]! [group] {event} {aupat} [++once] [++nested] {cmd} |
149 Remove all autocommands associated with {event} and | 149 Remove all autocommands associated with {event} and |
150 {pat}, and add the command {cmd}. | 150 {aupat}, and add the command {cmd}. |
151 See |autocmd-once| for [++once]. | 151 See |autocmd-once| for [++once]. |
152 See |autocmd-nested| for [++nested]. | 152 See |autocmd-nested| for [++nested]. |
153 | 153 |
154 :au[tocmd]! [group] {event} {pat} | 154 :au[tocmd]! [group] {event} {aupat} |
155 Remove all autocommands associated with {event} and | 155 Remove all autocommands associated with {event} and |
156 {pat}. | 156 {aupat}. |
157 | 157 |
158 :au[tocmd]! [group] * {pat} | 158 :au[tocmd]! [group] * {aupat} |
159 Remove all autocommands associated with {pat} for all | 159 Remove all autocommands associated with {aupat} for |
160 events. | 160 all events. |
161 | 161 |
162 :au[tocmd]! [group] {event} | 162 :au[tocmd]! [group] {event} |
163 Remove ALL autocommands for {event}. | 163 Remove ALL autocommands for {event}. |
164 Warning: You should not do this without a group for | 164 Warning: You should not do this without a group for |
165 |BufRead| and other common events, it can break | 165 |BufRead| and other common events, it can break |
175 with ":augroup"); otherwise, Vim uses the group defined with [group]. | 175 with ":augroup"); otherwise, Vim uses the group defined with [group]. |
176 | 176 |
177 ============================================================================== | 177 ============================================================================== |
178 4. Listing autocommands *autocmd-list* | 178 4. Listing autocommands *autocmd-list* |
179 | 179 |
180 :au[tocmd] [group] {event} {pat} | 180 :au[tocmd] [group] {event} {aupat} |
181 Show the autocommands associated with {event} and | 181 Show the autocommands associated with {event} and |
182 {pat}. | 182 {aupat}. |
183 | 183 |
184 :au[tocmd] [group] * {pat} | 184 :au[tocmd] [group] * {aupat} |
185 Show the autocommands associated with {pat} for all | 185 Show the autocommands associated with {aupat} for all |
186 events. | 186 events. |
187 | 187 |
188 :au[tocmd] [group] {event} | 188 :au[tocmd] [group] {event} |
189 Show all autocommands for {event}. | 189 Show all autocommands for {event}. |
190 | 190 |
1309 WinNew When a new window was created. Not done for | 1309 WinNew When a new window was created. Not done for |
1310 the first window, when Vim has just started. | 1310 the first window, when Vim has just started. |
1311 Before a WinEnter event. | 1311 Before a WinEnter event. |
1312 | 1312 |
1313 ============================================================================== | 1313 ============================================================================== |
1314 6. Patterns *autocmd-patterns* *{pat}* | 1314 6. Patterns *autocmd-patterns* *{aupat}* |
1315 | 1315 |
1316 The {pat} argument can be a comma separated list. This works as if the | 1316 The {aupat} argument of `:autocmd` can be a comma separated list. This works as |
1317 command was given with each pattern separately. Thus this command: > | 1317 if the command was given with each pattern separately. Thus this command: > |
1318 :autocmd BufRead *.txt,*.info set et | 1318 :autocmd BufRead *.txt,*.info set et |
1319 Is equivalent to: > | 1319 Is equivalent to: > |
1320 :autocmd BufRead *.txt set et | 1320 :autocmd BufRead *.txt set et |
1321 :autocmd BufRead *.info set et | 1321 :autocmd BufRead *.info set et |
1322 | 1322 |
1323 The file pattern {pat} is tested for a match against the file name in one of | 1323 The file pattern {aupat} is tested for a match against the file name in one of |
1324 two ways: | 1324 two ways: |
1325 1. When there is no '/' in the pattern, Vim checks for a match against only | 1325 1. When there is no '/' in the pattern, Vim checks for a match against only |
1326 the tail part of the file name (without its leading directory path). | 1326 the tail part of the file name (without its leading directory path). |
1327 2. When there is a '/' in the pattern, Vim checks for a match against both the | 1327 2. When there is a '/' in the pattern, Vim checks for a match against both the |
1328 short file name (as you typed it) and the full file name (after expanding | 1328 short file name (as you typed it) and the full file name (after expanding |