36

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?

3
  • 18
    Easy mode is not easy Commented Dec 12, 2014 at 14:50
  • 1
    So use ctrl+q to quit easy mode, and never open it again Commented Jun 8, 2023 at 20:51
  • Ironic: the regular vim shows a greeting that includes a hint how to quit it, but the "easy" vim -y doesn't show any greetings or hints whatsoever. Commented Nov 19, 2024 at 12:20

5 Answers 5

39

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.

Sign up to request clarification or add additional context in comments.

3 Comments

Glad I could help. Don't forget: First rule is "Don't panic". Then, remember that Vim has excellent documentation.
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)
But this doesn't make sense to have this as default way of quitting easy mode, as it is made specifically for people who don't know vim's "model editing"... hence ctrl-q
17

-y option makes vim start in easy mode, you can type CTRL-L to return to normal mode and then type :q! to exit.

Comments

3

ctrl + q is used to quit easy mode.

5 Comments

This is excellent! I can't believe I never knew about this before!
no, it's not used to quit easy mode. ctrl+q is simply a shortcut in some desktop environments, so if you don't have one (no GUI, only CLI) it won't work, and it doesn't have any relation to vim.
No.. it works in tty(just to make sure i tried it). you might have some configuration overriding ctrl-q mapping, try running vim without configs vim -y -u NONE
@VaisakhKM I tried vim -y -u NONE and <c-q> still didn't work for me.
C-q only got added in 2022, since vim v8.2.4945 if I'm reading the git correctly. Another reason it might not work is some terminals may intercept C-s/C-q to freeze/unfreeze output and don't actually deliver them to apps. screen may too. Try running cat and pressing C-q, if you don't see ^Q — that's your problem & stty -ixon in ~/.bashrc may help.
1

I use the gVim Easy, and it works for me to add the set im! in the .gvimrc.

gVim Easy v.s. gVim

Comments

1

It's good to remember that vim and vim -y (gVim Easy) are almost identical except for these differences:

  • vim starts out in NORMAL mode; vim -y starts out in INSERT mode.
  • Esc, Ctrl-[, and Ctrl-C exit INSERT mode in vim. However, these do not work in vim -y. Instead, these have been replaced with Ctrl-L.
  • Ctrl-Q allows the user to quit vim -y with 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-easy vim command.)
  • 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-easy vim command. Otherwise, you'll get a No file name error.)

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 x where 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:

  1. 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.

  2. vim's normal way of exiting INSERT mode (that is, Esc, Ctrl-[, and Ctrl-C) have been replaced with Ctrl-L in vim -y (Vim Easy).

  3. The INSERT mode command of Ctrl-O works just as well in vim -y (Vim Easy) as it does in vim. So you can use it to your advantage to execute any NORMAL commands you want.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.