*autocmd.txt*   For Vim version 9.1.  Last change: 2023 May 20


		  VIM REFERENCE MANUAL    by Bram Moolenaar


Automatic commands				*autocommand* *autocommands*

For a basic explanation, see section |40.3| in the user manual.

1.  Introduction		|autocmd-intro|
2.  Defining autocommands	|autocmd-define|
3.  Removing autocommands	|autocmd-remove|
4.  Listing autocommands	|autocmd-list|
5.  Events			|autocmd-events|
6.  Patterns			|autocmd-patterns|
7.  Buffer-local autocommands	|autocmd-buflocal|
8.  Groups			|autocmd-groups|
9.  Executing autocommands	|autocmd-execute|
10. Using autocommands		|autocmd-use|
11. Disabling autocommands	|autocmd-disable|


==============================================================================
1. Introduction						*autocmd-intro*

You can specify commands to be executed automatically when reading or writing
a file, when entering or leaving a buffer or window, and when exiting Vim.
For example, you can create an autocommand to set the 'cindent' option for
files matching *.c.  You can also use autocommands to implement advanced
features, such as editing compressed files (see |gzip-example|).  The usual
place to put autocommands is in your .vimrc or .exrc file.

				*E203* *E204* *E143* *E855* *E937* *E952*
WARNING: Using autocommands is very powerful, and may lead to unexpected side
effects.  Be careful not to destroy your text.
- It's a good idea to do some testing on an expendable copy of a file first.
  For example: If you use autocommands to decompress a file when starting to
  edit it, make sure that the autocommands for compressing when writing work
  correctly.
- Be prepared for an error halfway through (e.g., disk full).  Vim will mostly
  be able to undo the changes to the buffer, but you may have to clean up the
  changes to other files by hand (e.g., compress a file that has been
  decompressed).
- If the BufRead* events allow you to edit a compressed file, the FileRead*
  events should do the same (this makes recovery possible in some rare cases).
  It's a good idea to use the same autocommands for the File* and Buf* events
  when possible.

Recommended use:
- Always use a group, so that it's easy to delete the autocommand.
- Keep the command itself short, call a function to do more work.
- Make it so that the script it is defined in can be sourced several times
  without the autocommand being repeated.

Example in Vim9 script: >
   autocmd_add({replace: true,
		group:   'DemoGroup',
		event:   'BufEnter',
		pattern: '*.txt',
		cmd:     'call DemoBufEnter()'
		})

In legacy script: >
   call autocmd_add(#{replace: v:true,
		    \ group: 'DemoGroup',
		    \ event: 'BufEnter',
		    \ pattern: '*.txt',
		    \ cmd: 'call DemoBufEnter()'
		    \ })

==============================================================================
2. Defining autocommands				*autocmd-define*

							*:au* *:autocmd*
:au[tocmd] [group] {event} {aupat} [++once] [++nested] {cmd}
			Add {cmd} to the list of commands that Vim will
			execute automatically on {event} for a file matching
			{aupat} |autocmd-patterns|.
			Here {event} cannot be "*".  *E1155*
			Note: A quote character is seen as argument to the
			:autocmd and won't start a comment.
			Vim always adds the {cmd} after existing autocommands,
			so that the autocommands execute in the order in which
			they were given.
			See |autocmd-nested| for [++nested].  "nested"
			(without the ++) can also be used, for backwards
			compatibility, but not in |Vim9| script. *E1078*
							*autocmd-once*
			If [++once] is supplied the command is executed once,
			then removed ("one shot").

The special pattern <buffer> or <buffer=N> defines a buffer-local autocommand.
See |autocmd-buflocal|.

If the `:autocmd` is in Vim9 script (a script that starts with `:vim9script`
and in a `:def` function) then {cmd} will be executed as in Vim9
script.  Thus this depends on where the autocmd is defined, not where it is
triggered.
							*:autocmd-block*
{cmd} can be a block, like with `:command`, see |:command-repl|.  Example: >
	au BufReadPost *.xml {
		  setlocal matchpairs+=<:>
		  /<start
		}

The |autocmd_add()| function can be used to add a list of autocmds and autocmd
groups from a Vim script.  It is preferred if you have anything that would
require using `:execute` with `:autocmd`.

Note: The ":autocmd" command can only be followed by another command when the
'|' appears where the pattern is expected.  This works: >
	:augroup mine | au! BufRead | augroup END
But this sees "augroup" as part of the defined command: >
	:augroup mine | au! BufRead * | augroup END
	:augroup mine | au BufRead * set tw=70 | augroup END
Instead you can put the group name into the command: >
	:au! mine BufRead *
	:au mine BufRead * set tw=70
Or use `:execute`: >
	:augroup mine | exe "au! BufRead *" | augroup END
	:augroup mine | exe "au BufRead * set tw=70" | augroup END

<							*autocmd-expand*
Note that special characters (e.g., "%", "<cword>") in the ":autocmd"
arguments are not expanded when the autocommand is defined.  These will be
expanded when the Event is recognized, and the {cmd} is executed.  The only
exception is that "<sfile>" is expanded when the autocmd is defined.  Example:
>
	:au BufNewFile,BufRead *.html so <sfile>:h/html.vim

Here Vim expands <sfile> to the name of the file containing this line.

`:autocmd` adds to the list of autocommands regardless of whether they are
already present.  When your .vimrc file is sourced twice, the autocommands
will appear twice.  To avoid this, define your autocommands in a group, so
that you can easily clear them: >

	augroup vimrc
	  " Remove all vimrc autocommands
	  autocmd!
	  au BufNewFile,BufRead *.html so <sfile>:h/html.vim
	augroup END

If you don't want to remove all autocommands, you can instead use a variable
to ensure that Vim includes the autocommands only once: >

	:if !exists("autocommands_loaded")
	:  let autocommands_loaded = 1
	:  au ...
	:endif

When the [group] argument is not given, Vim uses the current group (as defined
with ":augroup"); otherwise, Vim uses the group defined with [group].  Note
that [group] must have been defined before.  You cannot define a new group
with ":au group ..."; use ":augroup" for that.

While testing autocommands, you might find the 'verbose' option to be useful: >
	:set verbose=9
This setting makes Vim echo the autocommands as it executes them.

When defining an autocommand in a script, it will be able to call functions
local to the script and use mappings local to the script.  When the event is
triggered and the command executed, it will run in the context of the script
it was defined in.  This matters if |<SID>| is used in a command.

When executing the commands, the message from one command overwrites a
previous message.  This is different from when executing the commands
manually.  Mostly the screen will not scroll up, thus there is no hit-enter
prompt.  When one command outputs two messages this can happen anyway.

==============================================================================
3. Removing autocommands				*autocmd-remove*

In addition to the below described commands, the |autocmd_delete()| function can
be used to remove a list of autocmds and autocmd groups from a Vim script.

:au[tocmd]! [group] {event} {aupat} [++once] [++nested] {cmd}
			Remove all autocommands associated with {event} and
			{aupat}, and add the command {cmd}.
			See |autocmd-once| for [++once].
			See |autocmd-nested| for [++nested].

:au[tocmd]! [group] {event} {aupat}
			Remove all autocommands associated with {event} and
			{aupat}.

:au[tocmd]! [group] * {aupat}
			Remove all autocommands associated with {aupat} for
			all events.

:au[tocmd]! [group] {event}
			Remove ALL autocommands for {event}.
			Warning: You should not do this without a group for
			|BufRead| and other common events, it can break
			plugins, syntax highlighting, etc.

:au[tocmd]! [group]	Remove ALL autocommands.
			Note: a quote will be seen as argument to the :autocmd
			and won't start a comment.
			Warning: You should normally not do this without a
			group, it breaks plugins, syntax highlighting, etc.

When the [group] argument is not given, Vim uses the current group (as defined
with ":augroup"); otherwise, Vim uses the group defined with [group].

==============================================================================
4. Listing autocommands					*autocmd-list*

:au[tocmd] [group] {event} {aupat}
			Show the autocommands associated with {event} and
			{aupat}.

:au[tocmd] [group] * {aupat}
			Show the autocommands associated with {aupat} for all
			events.

:au[tocmd] [group] {event}
			Show all autocommands for {event}.

:au[tocmd] [group]	Show all autocommands.

If you provide the [group] argument, Vim lists only the autocommands for
[group]; otherwise, Vim lists the autocommands for ALL groups.  Note that this
argument behavior differs from that for defining and removing autocommands.

In order to list buffer-local autocommands, use a pattern in the form <buffer>
or <buffer=N>.  See |autocmd-buflocal|.

The |autocmd_get()| function can be used from a Vim script to get a list of
autocmds.

							*:autocmd-verbose*
When 'verbose' is non-zero, listing an autocommand will also display where it
was last defined. Example: >

    :verbose autocmd BufEnter
    FileExplorer  BufEnter
	*	  call s:LocalBrowse(expand("<amatch>"))
	    Last set from /usr/share/vim/vim-7.0/plugin/NetrwPlugin.vim
<
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
alphabetically 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" command |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 before a buffer becomes 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
|OptionSet|		after setting any option

	Startup and exit
|VimEnter|		after doing all the startup stuff
|GUIEnter|		after starting the GUI successfully
|GUIFailed|		after starting the GUI failed
|TermResponse|		after the terminal response to |t_RV| is received

|QuitPre|		when using `:quit`, before deciding whether to exit
|ExitPre|		when using a command that may make Vim exit
|VimLeavePre|		before exiting Vim, before writing the viminfo file
|VimLeave|		before exiting Vim, after writing the viminfo file

|VimSuspend|		when suspending Vim
|VimResume|		when Vim is resumed after being suspended

	Terminal
|TerminalOpen|		after a terminal buffer was created
|TerminalWinOpen|	after a terminal buffer was created in a new window

	Various
|FileChangedShell|	Vim notices that a file changed since editing started
|FileChangedShellPost|	After handling a file changed since editing started
|FileChangedRO|		before making the first change to a read-only file

|DiffUpdated|		after diffs have been updated
|DirChangedPre|		before the working directory will change
|DirChanged|		after the working directory has changed

|ShellCmdPost|		after executing a shell command
|ShellFilterPost|	after filtering with a shell command

|CmdUndefined|		a user command is used but it isn't defined
|FuncUndefined|		a user function is used but it isn't defined
|SpellFileMissing|	a spell file is used but it can't be found
|SourcePre|		before sourcing a Vim script
|SourcePost|		after sourcing a Vim script
|SourceCmd|		before sourcing a Vim script |Cmd-event|

|VimResized|		after the Vim window size changed
|FocusGained|		Vim got input focus
|FocusLost|		Vim lost input focus
|CursorHold|		the user doesn't press a key for a while
|CursorHoldI|		the user doesn't press a key for a while in Insert mode
|CursorMoved|		the cursor was moved in Normal mode
|CursorMovedI|		the cursor was moved in Insert mode

|WinNew|		after creating a new window
|TabNew|		after creating a new tab page
|WinClosed|		after closing a window
|TabClosed|		after closing a tab page
|WinEnter|		after entering another window
|WinLeave|		before leaving a window
|TabEnter|		after entering another tab page
|TabLeave|		before leaving a tab page
|CmdwinEnter|		after entering the command-line window
|CmdwinLeave|		before leaving the command-line window

|CmdlineChanged|	after a change was made to the command-line text
|CmdlineEnter|		after the cursor moves to the command line
|CmdlineLeave|		before the cursor leaves the command line

|InsertEnter|		starting Insert mode
|InsertChange|		when typing <Insert> while in Insert or Replace mode
|InsertLeave|		when leaving Insert mode
|InsertLeavePre|	just before leaving Insert mode
|InsertCharPre|		when a character was typed in Insert mode, before
			inserting it

|ModeChanged|		after changing the mode

|TextChanged|		after a change was made to the text in Normal mode
|TextChangedI|		after a change was made to the text in Insert mode
			when popup menu is not visible
|TextChangedP|		after a change was made to the text in Insert mode
			when popup menu visible
|TextChangedT|		after a change was made to the text in Terminal mode
|TextYankPost|		after text has been yanked or deleted

|SafeState|		nothing pending, going to wait for the user to type a
			character
|SafeStateAgain|	repeated SafeState

|ColorSchemePre|	before loading a color scheme
|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
|CompleteChanged|	after Insert mode completion menu changed
|CompleteDonePre|	after Insert mode completion is done, before clearing
			info
|CompleteDone|		after Insert mode completion is done, after clearing
			info

|User|			to be used in combination with ":doautocmd"
|SigUSR1|		after the SIGUSR1 signal has been detected

|WinScrolled|		after scrolling or resizing a window


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.
				Not triggered for the initial buffers created
				during startup.
				The BufCreate event is for historic reasons.
				NOTE: When this autocommand is executed, the
				current buffer "%" may be different from the
				buffer being created "<afile>".
							*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 "<afile>" and "<abuf>".
				Don't change to another buffer, it will cause
				problems.
							*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.
							*BufFilePre*
BufFilePre			Before changing the name of the current buffer
				with the ":file" or ":saveas" command.
							*BufHidden*
BufHidden			Just                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    