On 16/06/09 00:45, bcrem wrote:
>
> ...and if so, how do I activate it?
>
> I keep hitting ":wq" when I only mean to hit ":w", and closing vim w/
> all my files loaded...it's quite annoying.
>
> Any help appreciated...
Yes and no.
If you try to close vim (by :wq, :q, etc., but without an exclamation
mark), then if it leaves an unsaved file in your current session, Vim
will refuse to quit and give you an error message instead.
Of course, ":wqa!" means you want to save everything and quit (so Vim
will quit in that case unless there's something that cannot be saved,
such as a modified [No Name] buffer), and "qa!" means you want to quit
without saving anything, so in that case there surely won't be a
message, and Vim will quit.
To get a dialog instead of an error, you can either:
- To get it once, prefix the command with ":confirm", as in
:confirm q
- To get it always, set the 'confirm' option.
These "confirm" command and option require a Vim version compiled with
one of +dialog_con, +dialog_gui or +dialog_con_gui (depending on whether
you're running Console Vim or gvim), and they won't prevent Vim from
quitting when you issue the ":wq" command on the _only_ window remaining
(with the possible exception of a help window). For that, you can
override that command with an abbreviation, as follows:
if version < 700
cnoreabbr wq w
else
cnoreabbr <expr> wq
\ ((getcmdtype() == ':' && getcmdpos() <= 3)?
\ 'w' : 'wq')
endif
which will replace wq by w on the command line (and in Vim 7, where the
required functions exist, only at the _start_ of an _ex_ command-line).
Best regards,
Tony.
--
Every word is like an unnecessary stain on silence and nothingness.
-- Beckett
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---