在没有获取的情况下覆盖您是否真的想要写入它(是/否)?在vim编辑器中

时间:2011-05-19 09:32:55

标签: vim

如何摆脱帖子标题中提到的消息

1 个答案:

答案 0 :(得分:1)

从vims帮助:w!:

                            *:w!*
:[range]w[rite]! [++opt] {file}
            Write the specified lines to {file}.  Overwrite an
            existing file.

或者你是这样的人?:

                *'confirm'* *'cf'* *'noconfirm'* *'nocf'*
'confirm' 'cf'      boolean (default off)
            global
            {not in Vi}
    When 'confirm' is on, certain operations that would normally
    fail because of unsaved changes to a buffer, e.g. ":q" and ":e",
    instead raise a |dialog| asking if you wish to save the current
    file(s).  You can still use a ! to unconditionally |abandon| a buffer.
    If 'confirm' is off you can still activate confirmation for one
    command only (this is most useful in mappings) with the |:confirm|
    command.
    Also see the |confirm()| function and the 'v' flag in 'guioptions'.

或者甚至是autowrite / autowriteall:

                 *'autowrite'* *'aw'* *'noautowrite'* *'noaw'*
'autowrite' 'aw'    boolean (default off)
            global
    Write the contents of the file, if it has been modified, on each
    :next, :rewind, :last, :first, :previous, :stop, :suspend, :tag, :!,
    :make, CTRL-] and CTRL-^ command; and when a :buffer, CTRL-O, CTRL-I,
    '{A-Z0-9}, or `{A-Z0-9} command takes one to another file.
    Note that for some commands the 'autowrite' option is not used, see
    'autowriteall' for that.

             *'autowriteall'* *'awa'* *'noautowriteall'* *'noawa'*
'autowriteall' 'awa'    boolean (default off)
            global
            {not in Vi}
    Like 'autowrite', but also used for commands ":edit", ":enew", ":quit",
    ":qall", ":exit", ":xit", ":recover" and closing the Vim window.
    Setting this option also implies that Vim behaves like 'autowrite' has
    been set.

vims帮助系统的一个美好未来是你键入内容然后按“ctrl-d”,vim将显示所有匹配的条目:

:help autowrite ctrl-d
'autowrite' 'autowriteall' 'noautowrite' 'noautowriteall'

您还可以做的是,只要焦点发生变化,即可将vim写入文件,方法是将其添加到.vimrc文件中:

au FocusLost * :wa