Mercurial > vim
comparison runtime/doc/autocmd.txt @ 9653:01c9630e80e0 v7.4.2103
commit https://github.com/vim/vim/commit/e99e84497b89e5f91df519790802770920ecf4fe
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Jul 26 20:43:40 2016 +0200
patch 7.4.2103
Problem: Can't have "augroup END" right after ":au!".
Solution: Check for the bar character before the command argument.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Tue, 26 Jul 2016 20:45:06 +0200 |
parents | 42a8a81decdf |
children | 35ce559b8553 |
comparison
equal
deleted
inserted
replaced
9652:1869038e346b | 9653:01c9630e80e0 |
---|---|
50 when possible. | 50 when possible. |
51 | 51 |
52 ============================================================================== | 52 ============================================================================== |
53 2. Defining autocommands *autocmd-define* | 53 2. Defining autocommands *autocmd-define* |
54 | 54 |
55 Note: The ":autocmd" command cannot be followed by another command, since any | |
56 '|' is considered part of the command. | |
57 | |
58 *:au* *:autocmd* | 55 *:au* *:autocmd* |
59 :au[tocmd] [group] {event} {pat} [nested] {cmd} | 56 :au[tocmd] [group] {event} {pat} [nested] {cmd} |
60 Add {cmd} to the list of commands that Vim will | 57 Add {cmd} to the list of commands that Vim will |
61 execute automatically on {event} for a file matching | 58 execute automatically on {event} for a file matching |
62 {pat} |autocmd-patterns|. | 59 {pat} |autocmd-patterns|. |
64 so that the autocommands execute in the order in which | 61 so that the autocommands execute in the order in which |
65 they were given. See |autocmd-nested| for [nested]. | 62 they were given. See |autocmd-nested| for [nested]. |
66 | 63 |
67 The special pattern <buffer> or <buffer=N> defines a buffer-local autocommand. | 64 The special pattern <buffer> or <buffer=N> defines a buffer-local autocommand. |
68 See |autocmd-buflocal|. | 65 See |autocmd-buflocal|. |
66 | |
67 Note: The ":autocmd" command can only be followed by another command when the | |
68 '|' appears before {cmd}. This works: > | |
69 :augroup mine | au! BufRead | augroup END | |
70 But this sees "augroup" as part of the defined command: > | |
71 :augroup mine | au BufRead * set tw=70 | augroup END | |
69 | 72 |
70 Note that special characters (e.g., "%", "<cword>") in the ":autocmd" | 73 Note that special characters (e.g., "%", "<cword>") in the ":autocmd" |
71 arguments are not expanded when the autocommand is defined. These will be | 74 arguments are not expanded when the autocommand is defined. These will be |
72 expanded when the Event is recognized, and the {cmd} is executed. The only | 75 expanded when the Event is recognized, and the {cmd} is executed. The only |
73 exception is that "<sfile>" is expanded when the autocmd is defined. Example: | 76 exception is that "<sfile>" is expanded when the autocmd is defined. Example: |