# HG changeset patch # User vimboss # Date 1133989471 0 # Node ID 1ef373b131264604ba90e80001b66def2436eaf3 # Parent 8eb0b93ea26c63a91334af8edc899aaff8335b33 updated for version 7.0164 diff --git a/runtime/doc/autocmd.txt b/runtime/doc/autocmd.txt --- a/runtime/doc/autocmd.txt +++ b/runtime/doc/autocmd.txt @@ -1,4 +1,4 @@ -*autocmd.txt* For Vim version 7.0aa. Last change: 2005 Nov 21 +*autocmd.txt* For Vim version 7.0aa. Last change: 2005 Dec 07 VIM REFERENCE MANUAL by Bram Moolenaar @@ -169,18 +169,195 @@ See |:verbose-cmd| for more information. ============================================================================== 5. Events *autocmd-events* *E215* *E216* +You can specify a comma-separated list of event names. No white space can be +used in this list. The command applies to all the events in the list. + +For READING FILES there are four kinds of events possible: + BufNewFile starting to edit a non-existent file + BufReadPre BufReadPost starting to edit an existing file + FilterReadPre FilterReadPost read the temp file with filter output + FileReadPre FileReadPost any other file read +Vim uses only one of these four kinds when reading a file. The "Pre" and +"Post" events are both triggered, before and after reading the file. + +Note that the autocommands for the *ReadPre events and all the Filter events +are not allowed to change the current buffer (you will get an error message if +this happens). This is to prevent the file to be read into the wrong buffer. + +Note that the 'modified' flag is reset AFTER executing the BufReadPost +and BufNewFile autocommands. But when the 'modified' option was set by the +autocommands, this doesn't happen. + +You can use the 'eventignore' option to ignore a number of events or all +events. *autocommand-events* *{event}* Vim recognizes the following events. Vim ignores the case of event names (e.g., you can use "BUFread" or "bufread" instead of "BufRead"). +First an overview by function with a short explanation. Then the list +alpabetically with full explanations |autocmd-events-abc|. + +Name triggered by ~ + + Reading +|BufNewFile| starting to edit a file that doesn't exist +|BufReadPre| starting to edit a new buffer, before reading the file +|BufRead| starting to edit a new buffer, after reading the file +|BufReadPost| starting to edit a new buffer, after reading the file +|BufReadCmd| before starting to edit a new buffer |Cmd-event| + +|FileReadPre| before reading a file with a ":read" command +|FileReadPost| after reading a file with a ":read" command +|FileReadCmd| before reading a file with a ":read" comman |Cmd-event| + +|FilterReadPre| before reading a file from a filter command +|FilterReadPost| after reading a file from a filter command + +|StdinReadPre| before reading from stdin into the buffer +|StdinReadPost| After reading from the stdin into the buffer + + Writing +|BufWrite| starting to write the whole buffer to a file +|BufWritePre| starting to write the whole buffer to a file +|BufWritePost| after writing the whole buffer to a file +|BufWriteCmd| before writing the whole buffer to a file |Cmd-event| + +|FileWritePre| starting to write part of a buffer to a file +|FileWritePost| after writing part of a buffer to a file +|FileWriteCmd| before writing part of a buffer to a file |Cmd-event| + +|FileAppendPre| starting to append to a file +|FileAppendPost| after appending to a file +|FileAppendCmd| before appending to a file |Cmd-event| + +|FilterWritePre| starting to write a file for a filter command or diff +|FilterWritePost| after writing a file for a filter command or diff + + Buffers +|BufAdd| just after adding a buffer to the buffer list +|BufCreate| just after adding a buffer to the buffer list +|BufDelete| before deleting a buffer from the buffer list +|BufWipeout| before completely deleting a buffer + +|BufFilePre| before changing the name of the current buffer +|BufFilePost| after changing the name of the current buffer + +|BufEnter| after entering a buffer +|BufLeave| before leaving to another buffer +|BufWinEnter| after a buffer is displayed in a window +|BufWinLeave| before a buffer is removed from a window + +|BufUnload| before unloading a buffer +|BufHidden| just after a buffer has become hidden +|BufNew| just after creating a new buffer + +|SwapExists| detected an existing swap file + + Options +|FileType| when the 'filetype' option has been set +|Syntax| when the 'syntax' option has been set +|EncodingChanged| after the 'encoding' option has been changed +|TermChanged| after the value of 'term' has changed + + Startup and exit +|VimEnter| after doing all the startup stuff +|GUIEnter| after starting the GUI successfully +|TermResponse| after the termainal response to |t_RV| is received + +|VimLeavePre| before exiting Vim, before writing the viminfo file +|VimLeave| before exiting Vim, after writing the viminfo file + + Various +|FileChangedShell| Vim notices that a file changed since editing started +|FileChangedRO| before making the first change to a read-only file + +|FuncUndefined| a user function is used but it isn't defined + +|FocusGained| Vim got input focus +|FocusLost| Vim lost input focus +|CursorHold| the user doesn't press a key for a while + +|WinEnter| after entering another window +|WinLeave| before leaving a window +|CmdwinEnter| after entering the command-line window +|CmdwinLeave| before leaving the command-line window + +|InsertEnter| starting Insert mode +|InsertChange| when typing while in Insert or Replace mode +|InsertLeave| when leaving Insert mode + +|ColorScheme| after loading a color scheme + +|RemoteReply| a reply from a server Vim was received + +|QuickFixCmdPre| before a quickfix command is run +|QuickFixCmdPost| after a quickfix command is run + +|SessionLoadPost| after loading a session file + +|MenuPopup| just before showing the popup menu + +|User| to be used in combination with ":doautocmd" + + +The alphabetical list of autocommand events: *autocmd-events-abc* + + *BufCreate* *BufAdd* +BufAdd or BufCreate Just after creating a new buffer which is + added to the buffer list, or adding a buffer + to the buffer list. + Also used just after a buffer in the buffer + list has been renamed. + The BufCreate event is for historic reasons. + NOTE: When this autocommand is executed, the + current buffer "%" may be different from the + buffer being created "". + *BufDelete* +BufDelete Before deleting a buffer from the buffer list. + The BufUnload may be called first (if the + buffer was loaded). + Also used just before a buffer in the buffer + list is renamed. + NOTE: When this autocommand is executed, the + current buffer "%" may be different from the + buffer being deleted "". + *BufEnter* +BufEnter After entering a buffer. Useful for setting + options for a file type. Also executed when + starting to edit a buffer, after the + BufReadPost autocommands. + *BufFilePost* +BufFilePost After changing the name of the current buffer + with the ":file" or ":saveas" command. + *BufReadCmd* +BufFilePre Before changing the name of the current buffer + with the ":file" or ":saveas" command. + *BufHidden* +BufHidden Just after a buffer has become hidden. That + is, when there are no longer windows that show + the buffer, but the buffer is not unloaded or + deleted. Not used for ":qa" or ":q" when + exiting Vim. + NOTE: When this autocommand is executed, the + current buffer "%" may be different from the + buffer being unloaded "". + *BufLeave* +BufLeave Before leaving to another buffer. Also when + leaving or closing the current window and the + new current window is not for the same buffer. + Not used for ":qa" or ":q" when exiting Vim. + *BufNew* +BufNew Just after creating a new buffer. Also used + just after a buffer has been renamed. When + the buffer is added to the buffer list BufAdd + will be triggered too. + NOTE: When this autocommand is executed, the + current buffer "%" may be different from the + buffer being created "". *BufNewFile* BufNewFile When starting to edit a file that doesn't exist. Can be used to read in a skeleton file. - *BufReadPre* *E200* *E201* -BufReadPre When starting to edit a new buffer, before - reading the file into the buffer. Not used - if the file doesn't exist. *BufRead* *BufReadPost* BufRead or BufReadPost When starting to edit a new buffer, after reading the file into the buffer, before @@ -190,63 +367,49 @@ BufRead or BufReadPost When starting to This does NOT work for ":r file". Not used when the file doesn't exist. Also used after successfully recovering a file. - *BufReadCmd* + *BufReadPre* *E200* *E201* BufReadCmd Before starting to edit a new buffer. Should read the file into the buffer. |Cmd-event| *BufFilePre* -BufFilePre Before changing the name of the current buffer - with the ":file" or ":saveas" command. - *BufFilePost* -BufFilePost After changing the name of the current buffer - with the ":file" or ":saveas" command. - *FileReadPre* -FileReadPre Before reading a file with a ":read" command. - *FileReadPost* -FileReadPost After reading a file with a ":read" command. - Note that Vim sets the '[ and '] marks to the - first and last line of the read. This can be - used to operate on the lines just read. - *FileReadCmd* -FileReadCmd Before reading a file with a ":read" command. - Should do the reading of the file. |Cmd-event| - *FilterReadPre* *E135* -FilterReadPre Before reading a file from a filter command. - Vim checks the pattern against the name of - the current buffer, not the name of the - temporary file that is the output of the - filter command. - Not triggered when 'shelltemp' is off. - *FilterReadPost* -FilterReadPost After reading a file from a filter command. - Vim checks the pattern against the name of - the current buffer as with FilterReadPre. - Not triggered when 'shelltemp' is off. - *FileType* -FileType When the 'filetype' option has been set. - can be used for the name of the file - where this option was set, and for - the new value of 'filetype'. - See |filetypes|. - *Syntax* -Syntax When the 'syntax' option has been set. - can be used for the name of the file - where this option was set, and for - the new value of 'syntax'. - See |:syn-on|. - *StdinReadPre* -StdinReadPre Before reading from stdin into the buffer. - Only used when the "-" argument was used when - Vim was started |--|. - *StdinReadPost* -StdinReadPost After reading from the stdin into the buffer, - before executing the modelines. Only used - when the "-" argument was used when Vim was - started |--|. +BufReadPre When starting to edit a new buffer, before + reading the file into the buffer. Not used + if the file doesn't exist. + *BufUnload* +BufUnload Before unloading a buffer. This is when the + text in the buffer is going to be freed. This + may be after a BufWritePost and before a + BufDelete. Also used for all buffers that are + loaded when Vim is going to exit. + NOTE: When this autocommand is executed, the + current buffer "%" may be different from the + buffer being unloaded "". + *BufWinEnter* +BufWinEnter After a buffer is displayed in a window. This + can be when the buffer is loaded (after + processing the modelines), when a hidden + buffer is displayed in a window (and is no + longer hidden) or a buffer already visible in + a window is also displayed in another window. + *BufWinLeave* +BufWinLeave Before a buffer is removed from a window. + Not when it's still visible in another window. + Also triggered when exiting. It's triggered + before BufUnload or BufHidden. + NOTE: When this autocommand is executed, the + current buffer "%" may be different from the + buffer being unloaded "". + *BufWipeout* +BufWipeout Before completely deleting a buffer. The + BufUnload and BufDelete events may be called + first (if the buffer was loaded and was in the + buffer list). Also used just before a buffer + is renamed (also when it's not in the buffer + list). + NOTE: When this autocommand is executed, the + current buffer "%" may be different from the + buffer being deleted "". *BufWrite* *BufWritePre* BufWrite or BufWritePre Before writing the whole buffer to a file. - *BufWritePost* -BufWritePost After writing the whole buffer to a file - (should undo the commands for BufWritePre). *BufWriteCmd* BufWriteCmd Before writing the whole buffer to a file. Should do the writing of the file and reset @@ -254,42 +417,68 @@ BufWriteCmd Before writing the whole b 'cpo' and writing to another file |cpo-+|. The buffer contents should not be changed. |Cmd-event| - *FileWritePre* -FileWritePre Before writing to a file, when not writing the - whole buffer. Use the '[ and '] marks for the - range of lines. - *FileWritePost* -FileWritePost After writing to a file, when not writing the - whole buffer. - *FileWriteCmd* -FileWriteCmd Before writing to a file, when not writing the - whole buffer. Should do the writing to the - file. Should not change the buffer. Use the - '[ and '] marks for the range of lines. - |Cmd-event| - *FileAppendPre* -FileAppendPre Before appending to a file. Use the '[ and '] - marks for the range of lines. - *FileAppendPost* -FileAppendPost After appending to a file. + *BufWritePost* +BufWritePost After writing the whole buffer to a file + (should undo the commands for BufWritePre). + *CmdwinEnter* +CmdwinEnter After entering the command-line window. + Useful for setting options specifically for + this special type of window. This is + triggered _instead_ of BufEnter and WinEnter. + is set to a single character, + indicating the type of command-line. + |cmdwin-char| + *CmdwinLeave* +CmdwinLeave Before leaving the command-line window. + Useful to clean up any global setting done + with CmdwinEnter. This is triggered _instead_ + of BufLeave and WinLeave. + is set to a single character, + indicating the type of command-line. + |cmdwin-char| + *ColorScheme* +ColorScheme After loading a color scheme. |:colorscheme| + *CursorHold* +CursorHold When the user doesn't press a key for the time + specified with 'updatetime'. Not re-triggered + until the user has pressed a key (i.e. doesn't + fire every 'updatetime' ms if you leave Vim to + make some coffee. :) See |CursorHold-example| + for previewing tags. + This event is only triggered in Normal mode. + Note: Interactive commands cannot be used for + this event. There is no hit-enter prompt, + the screen is updated directly (when needed). + Note: In the future there will probably be + another option to set the time. + Hint: to force an update of the status lines + use: > + :let &ro = &ro +< {only on Amiga, Unix, Win32, MSDOS and all GUI + versions} + *EncodingChanged* +EncodingChanged Fires off after the 'encoding' option has been + changed. Useful to set up fonts, for example. *FileAppendCmd* FileAppendCmd Before appending to a file. Should do the appending to the file. Use the '[ and '] marks for the range of lines.|Cmd-event| - *FilterWritePre* -FilterWritePre Before writing a file for a filter command or - making a diff. - Vim checks the pattern against the name of - the current buffer, not the name of the - temporary file that is the output of the - filter command. - Not triggered when 'shelltemp' is off. - *FilterWritePost* -FilterWritePost After writing a file for a filter command or - making a diff. - Vim checks the pattern against the name of - the current buffer as with FilterWritePre. - Not triggered when 'shelltemp' is off. + *FileAppendPost* +FileAppendPost After appending to a file. + *FileAppendPre* +FileAppendPre Before appending to a file. Use the '[ and '] + marks for the range of lines. + *FileChangedRO* +FileChangedRO Before making the first change to a read-only + file. Can be used to check-out the file from + a source control system. Not triggered when + the change was caused by an autocommand. + This event is triggered when making the first + change in a buffer or the first change after + 'readonly' was set, + just before the change is applied to the text. + WARNING: If the autocommand moves the cursor + the effect of the change is undefined. *FileChangedShell* FileChangedShell When Vim notices that the modification time of a file has changed since editing started. @@ -319,17 +508,64 @@ FileChangedShell When Vim notices that commands for the FileChangedShell event no other FileChangedShell event will be triggered. - *FileChangedRO* -FileChangedRO Before making the first change to a read-only - file. Can be used to check-out the file from - a source control system. Not triggered when - the change was caused by an autocommand. - This event is triggered when making the first - change in a buffer or the first change after - 'readonly' was set, - just before the change is applied to the text. - WARNING: If the autocommand moves the cursor - the effect of the change is undefined. + *FileEncoding* +FileEncoding Obsolete. It still works and is equivalent + to |EncodingChanged|. + *FileReadCmd* +FileReadCmd Before reading a file with a ":read" command. + Should do the reading of the file. |Cmd-event| + *FileReadPost* +FileReadPost After reading a file with a ":read" command. + Note that Vim sets the '[ and '] marks to the + first and last line of the read. This can be + used to operate on the lines just read. + *FileReadPre* +FileReadPre Before reading a file with a ":read" command. + *FileType* +FileType When the 'filetype' option has been set. + can be used for the name of the file + where this option was set, and for + the new value of 'filetype'. + See |filetypes|. + *FileWriteCmd* +FileWriteCmd Before writing to a file, when not writing the + whole buffer. Should do the writing to the + file. Should not change the buffer. Use the + '[ and '] marks for the range of lines. + |Cmd-event| + *FileWritePost* +FileWritePost After writing to a file, when not writing the + whole buffer. + *FileWritePre* +FileWritePre Before writing to a file, when not writing the + whole buffer. Use the '[ and '] marks for the + range of lines. + *FilterReadPost* +FilterReadPost After reading a file from a filter command. + Vim checks the pattern against the name of + the current buffer as with FilterReadPre. + Not triggered when 'shelltemp' is off. + *FilterReadPre* *E135* +FilterReadPre Before reading a file from a filter command. + Vim checks the pattern against the name of + the current buffer, not the name of the + temporary file that is the output of the + filter command. + Not triggered when 'shelltemp' is off. + *FilterWritePost* +FilterWritePost After writing a file for a filter command or + making a diff. + Vim checks the pattern against the name of + the current buffer as with FilterWritePre. + Not triggered when 'shelltemp' is off. + *FilterWritePre* +FilterWritePre Before writing a file for a filter command or + making a diff. + Vim checks the pattern against the name of + the current buffer, not the name of the + temporary file that is the output of the + filter command. + Not triggered when 'shelltemp' is off. *FocusGained* FocusGained When Vim got input focus. Only for the GUI version and a few console versions where this @@ -345,104 +581,134 @@ FuncUndefined When a user function is when it's used. Both and are set to the name of the function. See |autoload-functions|. - *CursorHold* -CursorHold When the user doesn't press a key for the time - specified with 'updatetime'. Not re-triggered - until the user has pressed a key (i.e. doesn't - fire every 'updatetime' ms if you leave Vim to - make some coffee. :) See |CursorHold-example| - for previewing tags. - This event is only triggered in Normal mode. - Note: Interactive commands cannot be used for - this event. There is no hit-enter prompt, - the screen is updated directly (when needed). - Note: In the future there will probably be - another option to set the time. - Hint: to force an update of the status lines - use: > - :let &ro = &ro -< {only on Amiga, Unix, Win32, MSDOS and all GUI - versions} - *BufEnter* -BufEnter After entering a buffer. Useful for setting - options for a file type. Also executed when - starting to edit a buffer, after the - BufReadPost autocommands. - *BufLeave* -BufLeave Before leaving to another buffer. Also when - leaving or closing the current window and the - new current window is not for the same buffer. - Not used for ":qa" or ":q" when exiting Vim. - *BufWinEnter* -BufWinEnter After a buffer is displayed in a window. This - can be when the buffer is loaded (after - processing the modelines), when a hidden - buffer is displayed in a window (and is no - longer hidden) or a buffer already visible in - a window is also displayed in another window. - *BufWinLeave* -BufWinLeave Before a buffer is removed from a window. - Not when it's still visible in another window. - Also triggered when exiting. It's triggered - before BufUnload or BufHidden. - NOTE: When this autocommand is executed, the - current buffer "%" may be different from the - buffer being unloaded "". - *BufUnload* -BufUnload Before unloading a buffer. This is when the - text in the buffer is going to be freed. This - may be after a BufWritePost and before a - BufDelete. Also used for all buffers that are - loaded when Vim is going to exit. - NOTE: When this autocommand is executed, the - current buffer "%" may be different from the - buffer being unloaded "". - *BufHidden* -BufHidden Just after a buffer has become hidden. That - is, when there are no longer windows that show - the buffer, but the buffer is not unloaded or - deleted. Not used for ":qa" or ":q" when - exiting Vim. - NOTE: When this autocommand is executed, the - current buffer "%" may be different from the - buffer being unloaded "". - *BufNew* -BufNew Just after creating a new buffer. Also used - just after a buffer has been renamed. When - the buffer is added to the buffer list BufAdd - will be triggered too. - NOTE: When this autocommand is executed, the - current buffer "%" may be different from the - buffer being created "". - *BufCreate* *BufAdd* -BufAdd or BufCreate Just after creating a new buffer which is - added to the buffer list, or adding a buffer - to the buffer list. - Also used just after a buffer in the buffer - list has been renamed. - The BufCreate event is for historic reasons. - NOTE: When this autocommand is executed, the - current buffer "%" may be different from the - buffer being created "". - *BufDelete* -BufDelete Before deleting a buffer from the buffer list. - The BufUnload may be called first (if the - buffer was loaded). - Also used just before a buffer in the buffer - list is renamed. - NOTE: When this autocommand is executed, the - current buffer "%" may be different from the - buffer being deleted "". - *BufWipeout* -BufWipeout Before completely deleting a buffer. The - BufUnload and BufDelete events may be called - first (if the buffer was loaded and was in the - buffer list). Also used just before a buffer - is renamed (also when it's not in the buffer - list). - NOTE: When this autocommand is executed, the - current buffer "%" may be different from the - buffer being deleted "". + *GUIEnter* +GUIEnter After starting the GUI successfully, and after + opening the window. It is triggered before + VimEnter when using gvim. Can be used to + position the window from a .gvimrc file: > + :autocmd GUIEnter * winpos 100 50 +< *InsertChange* +InsertChange When typing while in Insert or + Replace mode. The |v:insertmode| variable + indicates the new mode. + Be careful not to move the cursor or do + anything else that the user does not expect. + *InsertEnter* +InsertEnter When starting Insert mode. Also for Replace + mode and Virtual Replace mode. The + |v:insertmode| variable indicates the mode. + Be careful not to move the cursor or do + anything else that the user does not expect. + *InsertLeave* +InsertLeave When leaving Insert mode. Also when using + CTRL-O |i_CTRL-O|. But not for |i_CTRL-C|. + *MenuPopup* +MenuPopup Just before showing the popup menu (under the + right mouse button). Useful for adjusting the + menu for what is under the cursor or mouse + pointer. + The pattern is matched against a single + character representing the mode: + n Normal + v Visual + o Operator-pending + i Insert + c Commmand line + *QuickFixCmdPre* +QuickFixCmdPre Before a quickfix command is run (|:make|, + |:grep|, |:grepadd|, |:vimgrep|, + |:vimgrepadd|). The pattern is matched against + the command being run. When |:grep| is used + but 'grepprg' is set to "internal" it still + matches "grep". + This command cannot be used to set the + 'makeprg' and 'grepprg' variables. + If this command causes an error, the quickfix + command is not executed. + *QuickFixCmdPost* +QuickFixCmdPost Like QuickFixCmdPre, but after a quickfix + command is run. + *RemoteReply* +RemoteReply When a reply from a Vim that functions as + server was received |server2client()|. + is equal to the {serverid} from which + the reply was sent, and is the actual + reply string. + Note that even if an autocommand is defined, + the reply should be read with |remote_read()| + to consume it. + *SessionLoadPost* +SessionLoadPost After loading the session file created using + the |:mksession| command. + *StdinReadPost* +StdinReadPost After reading from the stdin into the buffer, + before executing the modelines. Only used + when the "-" argument was used when Vim was + started |--|. + *StdinReadPre* +StdinReadPre Before reading from stdin into the buffer. + Only used when the "-" argument was used when + Vim was started |--|. + *SwapExists* +SwapExists Detected an existing swap file when starting + to edit a file. Only when it is possible to + select a way to handle the situation, when Vim + would ask the user what to do. + The |v:swapname| variable holds the name of + the swap file found. + The |v:swapchoice| variable should be set to + a string with one character to tell what Vim + should do next: + 'o' open read-only + 'e' edit the file anyway + 'r' recover + 'd' delete the swap file + 'q' quit, don't edit the file + 'a' abort, like hitting CTRL-C + When set to an empty string the user will be + asked, as if there was no SwapExists autocmd. + Note: Do not try to change the buffer, the + results are unpredictable. + *Syntax* +Syntax When the 'syntax' option has been set. + can be used for the name of the file + where this option was set, and for + the new value of 'syntax'. + See |:syn-on|. + *TermChanged* +TermChanged After the value of 'term' has changed. Useful + for re-loading the syntax file to update the + colors, fonts and other terminal-dependent + settings. Executed for all loaded buffers. + *TermResponse* +TermResponse After the response to |t_RV| is received from + the terminal. The value of |v:termresponse| + can be used to do things depending on the + terminal version. + *User* +User Never executed automatically. To be used for + autocommands that are only executed with + ":doautocmd". + *UserGettingBored* +UserGettingBored When the user hits CTRL-C. Just kidding! :-) + *VimEnter* +VimEnter After doing all the startup stuff, including + loading .vimrc files, executing the "-c cmd" + arguments, creating all windows and loading + the buffers in them. + *VimLeave* +VimLeave Before exiting Vim, just after writing the + .viminfo file. Executed only once, like + VimLeavePre. + To detect an abnormal exit use |v:dying|. + *VimLeavePre* +VimLeavePre Before exiting Vim, just before writing the + .viminfo file. This is executed only once, + if there is a match with the name of what + happens to be the current buffer when exiting. + Mostly useful with a "*" pattern. > + :autocmd VimLeavePre * call CleanupStuff() +< To detect an abnormal exit use |v:dying|. *WinEnter* WinEnter After entering another window. Not done for the first window, when Vim has just started. @@ -459,145 +725,6 @@ WinLeave Before leaving a window. If executes the BufLeave autocommands before the WinLeave autocommands (but not for ":new"). Not used for ":qa" or ":q" when exiting Vim. - *CmdwinEnter* -CmdwinEnter After entering the command-line window. - Useful for setting options specifically for - this special type of window. This is - triggered _instead_ of BufEnter and WinEnter. - is set to a single character, - indicating the type of command-line. - |cmdwin-char| - *CmdwinLeave* -CmdwinLeave Before leaving the command-line window. - Useful to clean up any global setting done - with CmdwinEnter. This is triggered _instead_ - of BufLeave and WinLeave. - is set to a single character, - indicating the type of command-line. - |cmdwin-char| - *GUIEnter* -GUIEnter After starting the GUI successfully, and after - opening the window. It is triggered before - VimEnter when using gvim. Can be used to - position the window from a .gvimrc file: > - :autocmd GUIEnter * winpos 100 50 -< *VimEnter* -VimEnter After doing all the startup stuff, including - loading .vimrc files, executing the "-c cmd" - arguments, creating all windows and loading - the buffers in them. - *VimLeavePre* -VimLeavePre Before exiting Vim, just before writing the - .viminfo file. This is executed only once, - if there is a match with the name of what - happens to be the current buffer when exiting. - Mostly useful with a "*" pattern. > - :autocmd VimLeavePre * call CleanupStuff() -< To detect an abnormal exit use |v:dying|. - *VimLeave* -VimLeave Before exiting Vim, just after writing the - .viminfo file. Executed only once, like - VimLeavePre. - To detect an abnormal exit use |v:dying|. - *EncodingChanged* -EncodingChanged Fires off after the 'encoding' option has been - changed. Useful to set up fonts, for example. - *InsertEnter* -InsertEnter When starting Insert mode. Also for Replace - mode and Virtual Replace mode. The - |v:insertmode| variable indicates the mode. - Be careful not to move the cursor or do - anything else that the user does not expect. - *InsertChange* -InsertChange When typing while in Insert or - Replace mode. The |v:insertmode| variable - indicates the new mode. - Be careful not to move the cursor or do - anything else that the user does not expect. - *InsertLeave* -InsertLeave When leaving Insert mode. Also when using - CTRL-O |i_CTRL-O|. But not for |i_CTRL-C|. - *FileEncoding* -FileEncoding Obsolete. It still works and is equivalent - to |EncodingChanged|. - *ColorScheme* -ColorScheme After loading a color scheme. |:colorscheme| - *RemoteReply* -RemoteReply When a reply from a Vim that functions as - server was received |server2client()|. - is equal to the {serverid} from which - the reply was sent, and is the actual - reply string. - Note that even if an autocommand is defined, - the reply should be read with |remote_read()| - to consume it. - *TermChanged* -TermChanged After the value of 'term' has changed. Useful - for re-loading the syntax file to update the - colors, fonts and other terminal-dependent - settings. Executed for all loaded buffers. - *TermResponse* -TermResponse After the response to |t_RV| is received from - the terminal. The value of |v:termresponse| - can be used to do things depending on the - terminal version. -QuickFixCmdPre *QuickFixCmdPre* - Before a quickfix command is run (|:make|, - |:grep|, |:grepadd|, |:vimgrep|, - |:vimgrepadd|). The pattern is matched against - the command being run. When |:grep| is used - but 'grepprg' is set to "internal" it still - matches "grep". - This command cannot be used to set the - 'makeprg' and 'grepprg' variables. - If this command causes an error, the quickfix - command is not executed. -QuickFixCmdPost *QuickFixCmdPost* - like QuickFixCmdPre, but after a quickfix - command is run. - *SessionLoadPost* -SessionLoadPost After loading the session file created using - the |:mksession| command. - *MenuPopup* -MenuPopup Just before showing the popup menu (under the - right mouse button). Useful for adjusting the - menu for what is under the cursor or mouse - pointer. - The pattern is matched against a single - character representing the mode: - n Normal - v Visual - o Operator-pending - i Insert - c Commmand line - *UserGettingBored* -UserGettingBored When the user hits CTRL-C. Just kidding! :-) - *User* -User Never executed automatically. To be used for - autocommands that are only executed with - ":doautocmd". - -You can specify a comma-separated list of event names. No white space can be -used in this list. The command applies to all the events in the list. - -For READING FILES there are four kinds of events possible: - BufNewFile starting to edit a non-existent file - BufReadPre BufReadPost starting to edit an existing file - FilterReadPre FilterReadPost read the temp file with filter output - FileReadPre FileReadPost any other file read -Vim uses only one of these four kinds when reading a file. The "Pre" and -"Post" events are both triggered, before and after reading the file. - -Note that the autocommands for the *ReadPre events and all the Filter events -are not allowed to change the current buffer (you will get an error message if -this happens). This is to prevent the file to be read into the wrong buffer. - -Note that the 'modified' flag is reset AFTER executing the BufReadPost -and BufNewFile autocommands. But when the 'modified' option was set by the -autocommands, this doesn't happen. - -You can use the 'eventignore' option to ignore a number of events or all -events. ============================================================================== 6. Patterns *autocmd-patterns* *{pat}* diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -1,4 +1,4 @@ -*eval.txt* For Vim version 7.0aa. Last change: 2005 Dec 06 +*eval.txt* For Vim version 7.0aa. Last change: 2005 Dec 07 VIM REFERENCE MANUAL by Bram Moolenaar @@ -1272,12 +1272,13 @@ v:fcs_choice What should happen after a Vim behaves like it is empty, there is no warning message. *v:fname_in* *fname_in-variable* -v:fname_in The name of the input file. Only valid while evaluating: +v:fname_in The name of the input file. Valid while evaluating: option used for ~ 'charconvert' file to be converted 'diffexpr' original file 'patchexpr' original file 'printexpr' file to be printed + And set to the swap file name for |SwapExits|. *v:fname_out* *fname_out-variable* v:fname_out The name of the output file. Only valid while @@ -1400,6 +1401,23 @@ v:shell_error Result of the last shell c *v:statusmsg* *statusmsg-variable* v:statusmsg Last given status message. It's allowed to set this variable. + *v:swapname* *swapname-variable* +v:swapname Only valid when executing |SwapExists| autocommands: Name of + the swap file found. Read-only. + + *v:swapchoice* *swapchoice-variable* +v:swapchoice |SwapExists| autocommands can set this to the selected choice + for handling an existing swap file: + 'o' Open read-only + 'e' Edit anyway + 'r' Recover + 'd' Delete swapfile + 'q' Quit + 'a' Abort + The value should be a single-character string. An empty value + results in the user being asked, as would happen when there is + no SwapExists autocommand. The default is empty. + *v:termresponse* *termresponse-variable* v:termresponse The escape sequence returned by the terminal for the |t_RV| termcap entry. It is set when Vim receives an escape sequence diff --git a/runtime/doc/tags b/runtime/doc/tags --- a/runtime/doc/tags +++ b/runtime/doc/tags @@ -3034,7 +3034,6 @@ CursorHold autocmd.txt /*CursorHold* CursorHold-example windows.txt /*CursorHold-example* CursorIM mbyte.txt /*CursorIM* D change.txt /*D* -DCOP gui_x11.txt /*DCOP* DOS os_dos.txt /*DOS* DOS-format editing.txt /*DOS-format* DOS-format-write editing.txt /*DOS-format-write* @@ -3979,6 +3978,7 @@ SessionLoad-variable starting.txt /*Sess SessionLoadPost autocmd.txt /*SessionLoadPost* StdinReadPost autocmd.txt /*StdinReadPost* StdinReadPre autocmd.txt /*StdinReadPre* +SwapExists autocmd.txt /*SwapExists* Syntax autocmd.txt /*Syntax* T motion.txt /*T* TCL if_tcl.txt /*TCL* @@ -4197,7 +4197,6 @@ alt-input debugger.txt /*alt-input* alternate-file editing.txt /*alternate-file* amiga-window starting.txt /*amiga-window* ant.vim syntax.txt /*ant.vim* -antialias gui_x11.txt /*antialias* ap motion.txt /*ap* apache.vim syntax.txt /*apache.vim* append() eval.txt /*append()* @@ -4229,6 +4228,7 @@ autocmd-buflocal autocmd.txt /*autocmd-b autocmd-changes autocmd.txt /*autocmd-changes* autocmd-define autocmd.txt /*autocmd-define* autocmd-events autocmd.txt /*autocmd-events* +autocmd-events-abc autocmd.txt /*autocmd-events-abc* autocmd-execute autocmd.txt /*autocmd-execute* autocmd-groups autocmd.txt /*autocmd-groups* autocmd-intro autocmd.txt /*autocmd-intro* @@ -5624,7 +5624,6 @@ jumpto-diffs diff.txt /*jumpto-diffs* k motion.txt /*k* kcc uganda.txt /*kcc* kde gui_x11.txt /*kde* -kde-toolbar gui_x11.txt /*kde-toolbar* key-codes intro.txt /*key-codes* key-codes-changed version4.txt /*key-codes-changed* key-mapping map.txt /*key-mapping* @@ -5975,7 +5974,6 @@ new-5 version5.txt /*new-5* new-6 version6.txt /*new-6* new-7 version7.txt /*new-7* new-GTK-GUI version5.txt /*new-GTK-GUI* -new-KDE version7.txt /*new-KDE* new-MzScheme version7.txt /*new-MzScheme* new-Select-mode version5.txt /*new-Select-mode* new-View version6.txt /*new-View* @@ -6570,7 +6568,9 @@ substitute-CR version6.txt /*substitute- suffixes cmdline.txt /*suffixes* suspend starting.txt /*suspend* swap-file recover.txt /*swap-file* +swapchoice-variable eval.txt /*swapchoice-variable* swapfile-changed version4.txt /*swapfile-changed* +swapname-variable eval.txt /*swapname-variable* syn-sync-grouphere syntax.txt /*syn-sync-grouphere* syn-sync-groupthere syntax.txt /*syn-sync-groupthere* syn-sync-linecont syntax.txt /*syn-sync-linecont* @@ -6992,6 +6992,8 @@ v:scrollstart eval.txt /*v:scrollstart* v:servername eval.txt /*v:servername* v:shell_error eval.txt /*v:shell_error* v:statusmsg eval.txt /*v:statusmsg* +v:swapchoice eval.txt /*v:swapchoice* +v:swapname eval.txt /*v:swapname* v:termresponse eval.txt /*v:termresponse* v:this_session eval.txt /*v:this_session* v:throwpoint eval.txt /*v:throwpoint* @@ -7140,7 +7142,6 @@ vim-announce intro.txt /*vim-announce* vim-arguments starting.txt /*vim-arguments* vim-default-editor gui_w32.txt /*vim-default-editor* vim-dev intro.txt /*vim-dev* -vim-kpart gui_x11.txt /*vim-kpart* vim-mac intro.txt /*vim-mac* vim-modes intro.txt /*vim-modes* vim-modes-intro intro.txt /*vim-modes-intro* @@ -7160,7 +7161,6 @@ viminfo-file-marks starting.txt /*viminf viminfo-file-name starting.txt /*viminfo-file-name* viminfo-read starting.txt /*viminfo-read* viminfo-write starting.txt /*viminfo-write* -vimpart gui_x11.txt /*vimpart* vimrc starting.txt /*vimrc* vimrc-filetype usr_05.txt /*vimrc-filetype* vimrc-intro usr_05.txt /*vimrc-intro* diff --git a/src/globals.h b/src/globals.h --- a/src/globals.h +++ b/src/globals.h @@ -841,9 +841,12 @@ EXTERN int msg_silent INIT(= 0); /* don' EXTERN int emsg_silent INIT(= 0); /* don't print error messages */ EXTERN int cmd_silent INIT(= FALSE); /* don't echo the command line */ -#if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) -EXTERN int swap_exists_action INIT(= 0); /* use dialog when swap file - already exists */ +#if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) \ + || defined(FEAT_AUTOCMD) +# define HAS_SWAP_EXISTS_ACTION +EXTERN int swap_exists_action INIT(= SEA_NONE); + /* For dialog when swap file already + * exists. */ #endif EXTERN char_u *IObuff; /* sprintf's are done in this buffer, diff --git a/src/proto/memline.pro b/src/proto/memline.pro --- a/src/proto/memline.pro +++ b/src/proto/memline.pro @@ -1,32 +1,32 @@ /* memline.c */ -int ml_open __ARGS((void)); -void ml_setname __ARGS((buf_T *buf)); -void ml_open_files __ARGS((void)); -void ml_open_file __ARGS((buf_T *buf)); -void check_need_swap __ARGS((int newfile)); -void ml_close __ARGS((buf_T *buf, int del_file)); -void ml_close_all __ARGS((int del_file)); -void ml_close_notmod __ARGS((void)); -void ml_timestamp __ARGS((buf_T *buf)); -void ml_recover __ARGS((void)); -int recover_names __ARGS((char_u **fname, int list, int nr)); -void ml_sync_all __ARGS((int check_file, int check_char)); -void ml_preserve __ARGS((buf_T *buf, int message)); -char_u *ml_get __ARGS((linenr_T lnum)); -char_u *ml_get_pos __ARGS((pos_T *pos)); -char_u *ml_get_curline __ARGS((void)); -char_u *ml_get_cursor __ARGS((void)); -char_u *ml_get_buf __ARGS((buf_T *buf, linenr_T lnum, int will_change)); -int ml_line_alloced __ARGS((void)); -int ml_append __ARGS((linenr_T lnum, char_u *line, colnr_T len, int newfile)); -int ml_replace __ARGS((linenr_T lnum, char_u *line, int copy)); -int ml_delete __ARGS((linenr_T lnum, int message)); -void ml_setmarked __ARGS((linenr_T lnum)); -linenr_T ml_firstmarked __ARGS((void)); -void ml_clearmarked __ARGS((void)); -char_u *makeswapname __ARGS((char_u *fname, char_u *ffname, buf_T *buf, char_u *dir_name)); -char_u *get_file_in_dir __ARGS((char_u *fname, char_u *dname)); -void ml_setflags __ARGS((buf_T *buf)); -long ml_find_line_or_offset __ARGS((buf_T *buf, linenr_T lnum, long *offp)); -void goto_byte __ARGS((long cnt)); +extern int ml_open __ARGS((void)); +extern void ml_setname __ARGS((buf_T *buf)); +extern void ml_open_files __ARGS((void)); +extern void ml_open_file __ARGS((buf_T *buf)); +extern void check_need_swap __ARGS((int newfile)); +extern void ml_close __ARGS((buf_T *buf, int del_file)); +extern void ml_close_all __ARGS((int del_file)); +extern void ml_close_notmod __ARGS((void)); +extern void ml_timestamp __ARGS((buf_T *buf)); +extern void ml_recover __ARGS((void)); +extern int recover_names __ARGS((char_u **fname, int list, int nr)); +extern void ml_sync_all __ARGS((int check_file, int check_char)); +extern void ml_preserve __ARGS((buf_T *buf, int message)); +extern char_u *ml_get __ARGS((linenr_T lnum)); +extern char_u *ml_get_pos __ARGS((pos_T *pos)); +extern char_u *ml_get_curline __ARGS((void)); +extern char_u *ml_get_cursor __ARGS((void)); +extern char_u *ml_get_buf __ARGS((buf_T *buf, linenr_T lnum, int will_change)); +extern int ml_line_alloced __ARGS((void)); +extern int ml_append __ARGS((linenr_T lnum, char_u *line, colnr_T len, int newfile)); +extern int ml_replace __ARGS((linenr_T lnum, char_u *line, int copy)); +extern int ml_delete __ARGS((linenr_T lnum, int message)); +extern void ml_setmarked __ARGS((linenr_T lnum)); +extern linenr_T ml_firstmarked __ARGS((void)); +extern void ml_clearmarked __ARGS((void)); +extern char_u *makeswapname __ARGS((char_u *fname, char_u *ffname, buf_T *buf, char_u *dir_name)); +extern char_u *get_file_in_dir __ARGS((char_u *fname, char_u *dname)); +extern void ml_setflags __ARGS((buf_T *buf)); +extern long ml_find_line_or_offset __ARGS((buf_T *buf, linenr_T lnum, long *offp)); +extern void goto_byte __ARGS((long cnt)); /* vim: set ft=c : */ diff --git a/src/version.h b/src/version.h --- a/src/version.h +++ b/src/version.h @@ -36,5 +36,5 @@ #define VIM_VERSION_NODOT "vim70aa" #define VIM_VERSION_SHORT "7.0aa" #define VIM_VERSION_MEDIUM "7.0aa ALPHA" -#define VIM_VERSION_LONG "VIM - Vi IMproved 7.0aa ALPHA (2005 Dec 6)" -#define VIM_VERSION_LONG_DATE "VIM - Vi IMproved 7.0aa ALPHA (2005 Dec 6, compiled " +#define VIM_VERSION_LONG "VIM - Vi IMproved 7.0aa ALPHA (2005 Dec 7)" +#define VIM_VERSION_LONG_DATE "VIM - Vi IMproved 7.0aa ALPHA (2005 Dec 7, compiled "