LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Vim does not quit in terminal by escape and q or x or qw keys (https://www.linuxquestions.org/questions/linux-newbie-8/vim-does-not-quit-in-terminal-by-escape-and-q-or-x-or-qw-keys-4175471074/)

faisalnawazmir 07-26-2013 06:51 PM

Vim does not quit in terminal by escape and q or x or qw keys
 
I am using debian wheezy, I installed vim, it works quite well; excpet it does not quit in terminal by pressing the keys escape and pressing q, x or wq. I have to close the window adn then it closed.

What misktak most probably I have made....

Habitual 07-26-2013 07:04 PM

You're missing the : prefix for the wq!

:wq! = write, quit/exit
:q! = exit, no save
or...
ESC twice - ZZ is what I usually use.

https://www.linuxquestions.org/quest...or-4175469764/

faisalnawazmir 07-26-2013 10:12 PM

Vim does not quit
 
Thanks habitual for such informative response. but still with these keys it did not quit properly

suicidaleggroll 07-26-2013 10:22 PM

I suggest you search on Google or similar for how to use vi/vim. The key combinations you're asking about are extremely well established and explained, verbatim, thousands of times over.

It is literally a matter of:
Code:

vi file
i #switches to insert mode
type some stuff
Esc #switches back to command mode
:q!


doctor.sniff 07-26-2013 11:30 PM

Quote:

Originally Posted by suicidaleggroll (Post 4997663)
I suggest you search on Google or similar for how to use vi/vim. The key combinations you're asking about are extremely well established and explained, verbatim, thousands of times over.

It is literally a matter of:
Code:

vi file
i #switches to insert mode
type some stuff
Esc #switches back to command mode
:q!


This technique, doesn't save your edit.
you can save with this command->
ESC
:
wq or wq!

haertig 07-27-2013 01:27 PM

When I've been editing for a while, and maybe got distracted, I habitually hit ESC a couple of times before trying something in command mode. Even if I may have already been in command mode. Habit. Doesn't hurt anything. And then you're sure you're in command mode before you start typing commands. Same thing when I want to go into insert mode after having been distracted. I hit ESC a couple of times before hitting "i" (or whatever insert command key I want). Nothing worse than thinking you are in insert mode typing text when you are actually in commnd mode typing commands. You will mess up your file really horribly and really fast in that situation!

chrism01 07-29-2013 01:45 AM

As above, ensure you are in Cmd mode by hitting ESC once or twice (repeat doesn't hurt).
Now you can use cmds
Code:

:q      # quit, no save (will ask to save changes if any have been made)

:x      # exit with save

:q!    # quit and definitely don't ask to save changes

:w      # write current buffer to disk ie save any changes made up till now



All times are GMT -5. The time now is 04:19 PM.