def write_file(filename):
    """Write the current buffer.

    From the command mode, ``write_file`` uses Vi's ``:w`` command to
    write the current buffer.

    Usage:

    `In a config file:`

    .. code-block:: yaml

      - write_file: "message.txt"

    `Using the API:`

    .. code-block:: python

      ezvi.tools.write_file("message.txt")

    :type filename: str
    :param filename: The path towards where to save the current buffer.

    :rtype: str
    :return: ``:w`` plus a file name and a newline.
    """

    to_write = ":w " + filename + "\n"

    return to_write