> Hi,
> This may sound like a real newbie question, but when I do the "set -o vi"
> in the bash command line shell, if I hit <Esc> and v on the command line,
> it goes into vi editing mode. This is kind of cool, as I can exercise
> the full editing power of vi, and when I exit the editor it runs the command.
> Unfortunately, sometimes I may have a really powerful/dangerous/unnecessary
> command that I've typed, and all I want to do is just cancel, not execute the
> command. How do I do this?
> :q! doesn't seem to work, as the command still runs. :wq , well, I don't want
> to save anything, I just want to get out of the editor and return to the plain
> old bash prompt.
> Is this possible? Of course I can always kill the terminal that I'm running
> in to avoid running the command as soon as vi exits. Or I can try to press
> ctrl+C as fast as possible.
> I was hoping for a better alternative.
One way is to exit vim with the :cq command. See
:help :cq
That will quit vim with an error code telling bash that the editing
was unsuccessful.
Another is to delete the contents of the vim buffer before saving
and quitting as normal, e.g., dd if there is only one line in the
buffer or ggdG to if there is more than one line, followed by ZZ or
:wq to save and quit.
In this case, you _do_ want to save something because that something
is what bash will execute.
I usually use dd:wq because the :w makes me feel more sure that
the empty buffer has actually been written.
Regards,
Gary
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
No comments:
Post a Comment