News for hackers. Stuff that matters.
Re:Helping a Million Developers Exit Vim by ZenoArrow on Tuesday May 23, 2017 @01:42PM (#14403308)
I barely use any Vim, but I'm more confused about there being some hidden complexity in exiting Vim that I'm not aware of.

Isn't it just...

[Esc] :wq

...or...

[Esc] :q!

...depending if you want to save the current document or not?

Re:Helping a Million Developers Exit Vim by gtsteve on Tuesday May 23, 2017 @01:44PM (#14403330)
Imagine you don't know that. Now try to exit vim.
Re:Helping a Million Developers Exit Vim by ashark on Tuesday May 23, 2017 @01:48PM (#14403380)
Add in the bonus confusion that you may not have even been trying to run vim, and in fact may not know what it is (hey, everyone's a beginner some time), but have landed there due to a default $EDITOR value.

[EDIT] also, a typical mid-level computer user's tendency to slap "ESC" when panicked. Ha!

Re:Helping a Million Developers Exit Vim by fishywang on Tuesday May 23, 2017 @02:11PM (#14403662)
Which OS/Linux distribution set default $EDITOR to vim? Personally I've never seen one, and I don't think vim is a sane default value for $EDITOR.
Re:Helping a Million Developers Exit Vim by dom0 on Tuesday May 23, 2017 @02:32PM (#14403875)
I dunno if it's actually vim or some variation on it, but it is the default on, for example, Arch Linux, although I believe most other distros dropped me into it as well (e.g. git commit / rebase -i).

If there is such a thing as user hostile in the world of CLI tools, then dropping the user unannounced into vi with some open buffer most definitely counts as user hostile.

Re:Helping a Million Developers Exit Vim by recursive on Tuesday May 23, 2017 @02:29PM (#14403843)
Don't know about $EDITOR, but if you issue a git commit in Windows, and forget to specify -m, then you end up in vim.
Re:Helping a Million Developers Exit Vim by 0xFFFE on Tuesday May 23, 2017 @02:45PM (#14403986)
In Jessie, visudo lands you in nano, unless you explicitly set the $EDITOR.
Re:Helping a Million Developers Exit Vim by JdeBP on Friday May 26, 2017 @12:53PM (#14425454)
What are your thoughts on $VISUAL?
Re:Helping a Million Developers Exit Vim by bbcbasic on Tuesday May 23, 2017 @03:39PM (#14404515)
> you may not have even been trying to run vi

git rebase -i

For example

Re:Helping a Million Developers Exit Vim by tcoff91 on Tuesday May 23, 2017 @01:48PM (#14403383)
Ok, so anyone with any terminal experience but no vim experience would press <ctrl>-c.

Then, the program tells them "Type :quit<Enter> to exit Vim"

And if the user is capable of reading, they shouldn't have any problem.

If they don't know about ctrl-c, they shouldn't be using a terminal editor.

Re:Helping a Million Developers Exit Vim by zero_iq on Tuesday May 23, 2017 @01:56PM (#14403482)
Try actually following those instructions. They don't work. There is a step missing, and you may get warnings even if you know to hit escape first.
Re:Helping a Million Developers Exit Vim by Gracana on Tuesday May 23, 2017 @02:29PM (#14403839)
You don't have to hit escape, ctrl-c puts you in normal mode.
Re:Helping a Million Developers Exit Vim by Bartweiss on Tuesday May 23, 2017 @02:27PM (#14403813)
If vim opens and that's the first thing you try, then it'll work, yeah.

But if you've typed anything, this won't quite work. <ctrl> c will take you out of insert mode, but won't offer any prompt. <ctrl> c again will bring up the quit prompt, but that's not intuitive the way doing it the first time is. And if you type the wrong thing after the first <ctrl> c, you'll break back into insert mode and have to take another run at it.

I remember getting stuck in vim because git bash uses it as a default editor. It happened when I forgot to enter a commit message, which meant that I started typing a commit message and thereby lost the useful prompt when I went to quit.

edit: per another thread, this gets far worse if you don't realize the ':' is active and not a prompt to "type: quit". That error sets off a maze that will never show you the prompt again to find your mistake.

Re:Helping a Million Developers Exit Vim by dsp1234 on Tuesday May 23, 2017 @01:54PM (#14403453)
E37: No write since last change (add ! to override)
Re:Helping a Million Developers Exit Vim by ZenoArrow on Wednesday May 24, 2017 @01:32AM (#14407801)
In that case I'd just close the terminal window if I was running the terminal from a GUI session. Does that count?
Re:Helping a Million Developers Exit Vim by spydum on Tuesday May 23, 2017 @01:47PM (#14403361)
I think mostly it's people not being familiar with escape key. If you think about it, pretty rare you use Escape in anything other than a game..
Re:Helping a Million Developers Exit Vim by donarb on Tuesday May 23, 2017 @02:19PM (#14403736)
On the Mac, the escape key has been used forever in dialogs as a surrogate for the Cancel button or for dismissing dialogs where the results are non-destructive.
Re:Helping a Million Developers Exit Vim by deanstag on Tuesday May 23, 2017 @01:46PM (#14403356)
Correct. But as the article mentions, it might be confusing for developers who predominantly use IDEs and text editors that are not modal in nature.
Re:Helping a Million Developers Exit Vim by chocolatemario on Tuesday May 23, 2017 @01:46PM (#14403353)
Never forget ZZ. Or, my preferred method, suspend the process for later use.
Re:Helping a Million Developers Exit Vim by Etheryte on Tuesday May 23, 2017 @01:45PM (#14403340)
You can also <Esc>-ZZ to save the file and exit. Very convenient to remember if you use Vim a lot.
Re:Helping a Million Developers Exit Vim by tcoff91 on Tuesday May 23, 2017 @01:45PM (#14403346)
No, it really is that easy.

If you try to <ctrl>-c, the program even tells you to use :q

It's just become a meme at this point.

Re:Helping a Million Developers Exit Vim by masklinn on Tuesday May 23, 2017 @02:05PM (#14403590)
> If you try to <ctrl>-c, the program even tells you to use :q

And then you do and it helpfully adds ":q" to the buffer.

You're still in vim.

Re:Helping a Million Developers Exit Vim by splawn on Tuesday May 23, 2017 @02:17PM (#14403718)
If you hit ctrl-c then you are no longer in insert mode (ctrl-c acts like esc for some reason), so no, it won't add anything to the buffer and ":q" will get you out.

I don't blame people for being confused though.. I remember getting stuck in vim all the time back in the day because of a default $EDITOR value.

Re:Helping a Million Developers Exit Vim by jayflux on Tuesday May 23, 2017 @01:51PM (#14403413)
But why would i be pressing <ctrl>-c in the first place if i don't know any Vim commands?

Edit: ah quit foreground process, ignore me

Re:Helping a Million Developers Exit Vim by tcoff91 on Tuesday May 23, 2017 @01:54PM (#14403463)
<ctrl>-c is not a vim command. It's a universal terminal command.

<ctrl>-c is how you kill the foreground process in bash, zsh, sh, windows command line, etc...

If you don't know about <ctrl>-c you shouldn't be attempting to use a terminal based editor to begin with. Vim can't be blamed for people not knowing how to use a terminal.

Re:Helping a Million Developers Exit Vim by zeptomu on Tuesday May 23, 2017 @01:56PM (#14403476)
Because it is the standard command to kill (i.e. send SIGINT) running programs in a terminal? E.g. ping, top, etc. all quit using Ctrl-C.
Re:Helping a Million Developers Exit Vim by djtriptych on Tuesday May 23, 2017 @01:45PM (#14403349)
or :q or ZZ or qa(!) or wqa(!)

I love vim and I've used all of those at some point. I'd never pretend there's no learning curve, just that the learning curve is worth it.

Re:Helping a Million Developers Exit Vim by VT_Drew on Tuesday May 23, 2017 @01:57PM (#14403491)
ZZ also works as save and quit.
Re:Helping a Million Developers Exit Vim by optimuspaul on Tuesday May 23, 2017 @01:52PM (#14403425)
It baffles me that it isn't just ^C like every other unix program.
Re:Helping a Million Developers Exit Vim by rhinoceraptor on Tuesday May 23, 2017 @01:58PM (#14403503)
Every other unix program is not an interactive editor, they don't care if stdout is a teleprinter, a physical terminal or a terminal emulator.
Re:Helping a Million Developers Exit Vim by kbp on Tuesday May 23, 2017 @02:50PM (#14404053)
If you press ^C, it tells you how to quit. As to why it doesn't just exit, a lot of beginners would probably expect ^C in a text editor to copy text.
Re:Helping a Million Developers Exit Vim by bitcrusher on Tuesday May 23, 2017 @02:13PM (#14403685)
or even:

[Esc] :x

to save and exit.