Accidentally I typed vim -y install python-requests instead of yum ... and I do not know how to exit from vim now. Standard option with shift + : + q! does not work. Are there any options how to exit from vim without killing it?
5 Answers
With -y (easy mode), Vim defaults to insert mode, and you cannot permanently exit to normal mode via <Esc>. However, like in default Vim, you can issue a single normal mode command via <C-O>. So to exit, type <C-O>:q!<CR>.
Alternatively, there's a special <C-L> mapping for easy mode that returns to normal mode.
3 Comments
set noinsertmode (needs C-o as prefix in easy mode) will bring normal mode back, although it cannot revert all changes loaded in easy mode (see evim.vim in vim runtime directory)ctrl + q is used to quit easy mode.
5 Comments
vim -y -u NONEvim -y -u NONE and <c-q> still didn't work for me.cat and pressing C-q, if you don't see ^Q — that's your problem & stty -ixon in ~/.bashrc may help.I use the gVim Easy, and it works for me to add the set im! in the .gvimrc.
Comments
It's good to remember that vim and vim -y (gVim Easy) are almost identical except for these differences:
vimstarts out in NORMAL mode;vim -ystarts out in INSERT mode.- Esc, Ctrl-[, and Ctrl-C exit INSERT mode in
vim. However, these do not work invim -y. Instead, these have been replaced with Ctrl-L. - Ctrl-Q allows the user to quit
vim -ywith a Save prompt. (However, saving your file will only work if you specified the filename at the prompt, or previously saved it off with non-easyvimcommand.) - Ctrl-S will save your current file in
vim -y. (But just like with Ctrl-Q, saving your file will only work if you specified the filename at the prompt, or previously saved it off with non-easyvimcommand. Otherwise, you'll get aNo file nameerror.)
And it's good to remember this important similarity as well:
In INSERT mode, both vim and vim -y will allow you to use the Ctrl- commands that work during INSERT mode. Examples include:
- Ctrl-T to indent the current line.
- Ctrl-D to dedent (that is, un-indent) the current line.
- Ctrl-N and Ctrl-P to auto-complete the word currently being typed.
- Ctrl-R x to paste the contents of register
xwhere the cursor is.
and, relevant to this thread:
- Ctrl-O to temporarily enter NORMAL mode to issue one NORMAL-mode command (after which you'll immediately return to INSERT mode).
Hopefully you'll see that this last one (the Ctrl-O command) will allow you to save (with :w), save-and-quit (with :wq), discard unsaved changes (with :e!), as well as simply quit-without-saving (with :q!).
You can also use Ctrl-O followed by a non-ex command, like u (for "undo"), dd (to delete the current line), ZZ (to save-and-quit), and ZQ (to quit-without-saving).
So if you're not familiar with using Ctrl- commands in vim's INSERT mode, I strongly recommend learning at least the Ctrl-O command, as remembering that will help you figure out how to exit (and save documents in) vim -y. (While knowledge of Ctrl-L will help with vim -y, knowledge of Ctrl-O will help in both vim -y and vim.)
Key Takeaways
If there are only three things you remember from this post, remember these:
Ctrl-Q is the simple and straightforward way to exit
vim -y, but you won't be able to save your file if you haven't previously specified a filename for it.vim's normal way of exiting INSERT mode (that is, Esc, Ctrl-[, and Ctrl-C) have been replaced with Ctrl-L invim -y(Vim Easy).The INSERT mode command of Ctrl-O works just as well in
vim -y(Vim Easy) as it does invim. So you can use it to your advantage to execute any NORMAL commands you want.
vimshows a greeting that includes a hint how to quit it, but the "easy"vim -ydoesn't show any greetings or hints whatsoever.