Type Function
Object File
Library io.*
Return value none
Revision Release 2024.3703
Keywords setvbuf, files
See also io.open()


Sets the buffering mode for an output file (or console).

This function can be used to control buffering of file writes and console output. When buffering is disabled on console output (print() and calls to io.write()), the information (debug data) is displayed instantly on the Xcode console and Console.app for iPhone/iPad.


Disabling buffering can affect the performance of the app. The flushing of the buffer can be performed anytime by the io.flush() function.


File:setvbuf( mode [, size ] )
mode (required)

String. There are three available modes:

  • "no" — No buffering; the result of any output operation appears immediately.
  • "full" — Full buffering; output operation is performed only when the buffer is full (or when you explicitly flush the file (see io.flush())).
  • "line" — Line buffering; output is buffered until a newline is output or there is any input from some special files such as a Terminal device.
size (optional)

Number. Specifies the size of the buffer, in bytes. The default is an appropriate size.


io.output():setvbuf( "no" )  -- Disable output buffering for the console