News for hackers. Stuff that matters.
Re:Helping a Million Developers Exit Vim by vopi on Tuesday May 23, 2017 @01:42PM (#14403313)
It literally everytime you boot the first screen tells you how to quit and get help. So..read the screen that comes up Everytime? If you try Ctrl c it tells you it's :q.
Re:Helping a Million Developers Exit Vim by jayflux on Tuesday May 23, 2017 @01:47PM (#14403368)
> developers are often dropped into Vim from a git command or another situation where they didn’t expect to be, and they run into it infrequently enough to forget how they solved it last time.

So the first screen doesn't help in this situation

The sort of developers who get stuck in Vim are not the ones who are using it intentionally

Re:Helping a Million Developers Exit Vim by signal11 on Tuesday May 23, 2017 @01:52PM (#14403434)
Hitting Ctrl+C still works, it tells you to type ":quit<Enter>".
Re:Helping a Million Developers Exit Vim by masklinn on Tuesday May 23, 2017 @01:59PM (#14403518)
Why doesn't it just quit? That's as stupid as Python's

    >>> quit
    Use quit() or Ctrl-D (i.e. EOF) to exit
The software knows perfectly well what I'm trying to do FFS.
Re:Helping a Million Developers Exit Vim by StavrosK on Tuesday May 23, 2017 @02:08PM (#14403628)
Because it's an editor, and if it just quit on me every time I mistyped Ctrl-C just because you can't be bothered to type the right command, I would be quite angry.
Re:Helping a Million Developers Exit Vim by scrollaway on Tuesday May 23, 2017 @03:45PM (#14404580)
My GUI editors quit on me every time I mistype Ctrl+Q. I don't really see the difference.
Re:Helping a Million Developers Exit Vim by bdamm on Tuesday May 23, 2017 @04:52PM (#14405217)
Since I switch between Mac OS X, Windows, and Linux hosts, accidentally typing ctrl-c when I meant to type cmd-c (copy outside of Terminal) isn't such an infrequent error. I'm thankful that ctrl-c isn't mapped to quit without saving.
Re:Helping a Million Developers Exit Vim by khedoros1 on Tuesday May 23, 2017 @05:08PM (#14405363)
Well, and my GUI editors don't respond to single-letter commands. It would violate my expectations of their UIs if they did. Similarly, in vim, I expect ctrl+q to send an XON signal to my terminal emulator...not to quit my editor.

They're different programs with different UI conventions. I don't expect them to act the same. And I especially don't expect vim to change, after having 25 years of its own precedent and an additional 16 through vi.

Re:Helping a Million Developers Exit Vim by chipotle_coyote on Tuesday May 23, 2017 @04:28PM (#14405020)
I would think that in both the ^Q and ^C case, the editor in question is capable of prompting "Really exit? (Y/n)" or something to that effect.
Re:Helping a Million Developers Exit Vim by root_axis on Tuesday May 23, 2017 @04:13PM (#14404863)
Right... I think the point is that this behavior is not preferable.
Re:Helping a Million Developers Exit Vim by Piskvorrr on Tuesday May 23, 2017 @05:04PM (#14405334)
I do consider that a misfeature, especially since Ctrl+W and Ctrl+A are one key away and often carry commonly-used commands.
Re:Helping a Million Developers Exit Vim by _asummers on Tuesday May 23, 2017 @05:27PM (#14405521)
I have an entire section of my emacs file devoted to unbinding keys that accidentally close my editor.
Re:Helping a Million Developers Exit Vim by Macha on Tuesday May 23, 2017 @02:05PM (#14403593)
So it actually doesn't, it's basically just a hack around the fact that the repl is basically:

    while True:
        print(str(eval(input())))
Case in point:

    >>> x = str(quit)
    >>> x
    'Use quit() or Ctrl-Z plus Return to exit'
I suppose you could implement quit.__str__ as sys.exit(0), if you really wanted to avoid this problem.
Re:Helping a Million Developers Exit Vim by thoth on Tuesday May 23, 2017 @02:31PM (#14403858)
Whatever logic currently used to print the 'Use quit() or Ctrl-Z plus Return to exit' message could also... quit the REPL in the first place, right?

I don't program Python much but do its users constantly type "quit" but not actually want to quit such that the REPL special cases this situation?

Re:Helping a Million Developers Exit Vim by masklinn on Tuesday May 23, 2017 @03:54PM (#14404668)
> Whatever logic currently used to print the 'Use quit() or Ctrl-Z plus Return to exit' message could also... quit the REPL in the first place, right?

That one would probably be somewhat risky actually, that message is the "repr" of the quit object/function, displaying results at the repl invokes repr… but so does printing most containers, so e.g. `vars(__builtins__)` (to get a quick list of the builtins) would also quit the repl, which would be undesirable.

Re:Helping a Million Developers Exit Vim by wcoenen on Tuesday May 23, 2017 @04:47PM (#14405184)
There is no special logic behind it. It just prints the value of the variable with the name "quit", the same way it would print the value of the variable "foo" if you typed "foo".
Re:Helping a Million Developers Exit Vim by khedoros1 on Tuesday May 23, 2017 @05:16PM (#14405434)
The repl's basically supposed to help you write a program by matching the behavior of Python itself. What if I've got a variable called "quit" and I want to check its value?

The repl treats it specially because "quit", taken out of the context of the repl, makes sense as something to type in when trying to quit an unfamiliar program, not because actual Python programmers are likely to type it often.

Re:Helping a Million Developers Exit Vim by masklinn on Tuesday May 23, 2017 @02:11PM (#14403654)
> So it actually doesn't

It does, it just does not care.

> it's basically just a hack around the fact that the repl is basically:

I know what a REPL is. Here's an idea: it's not difficult to add an exit special case to the REPL.

> Case in point:

Case in point: the developers added a "help text" to tell users to go fuck themselves, knowing exactly what users wanted to do and refusing to do it. quit's repr didn't appear by magic, it was put there, knowingly, by people who understood exactly what they were doing.

Re:Helping a Million Developers Exit Vim by sbmassey on Tuesday May 23, 2017 @05:08PM (#14405367)
quit is not a piece of repl functionality, it is a python function that will exit the repl when called, with a string representation that gives that message. If I set quit = 1, or if I define my own quit() function, I don't want to have to be continually fighting the repl in order to inspect its value.
Re:Helping a Million Developers Exit Vim by monknomo on Tuesday May 23, 2017 @03:00PM (#14404147)
Humane programming is something I wish compiler and language builders would do more of
Re:Helping a Million Developers Exit Vim by marvin on Tuesday May 23, 2017 @05:54PM (#14405700)
Approximately 50% of the contributors in this thread argue actively against it, so I wouldn't hold my breath ;)
Re:Helping a Million Developers Exit Vim by monknomo on Tuesday May 23, 2017 @06:05PM (#14405781)
That was not lost on me. They're wrong, and kinda mean TBH, but someday someone will make a pretty good language, with a really helpful compiler/interpreter and will have the viral-fu to get it in use
Re:Helping a Million Developers Exit Vim by pishpash on Tuesday May 23, 2017 @04:09PM (#14404824)
It's insidiously more malevolent than that, considering how much productivity is wasted.
Re:Helping a Million Developers Exit Vim by Asooka on Tuesday May 23, 2017 @06:06PM (#14405788)
Plenty of good reasons for ^C not to quit, mostly having to do with the rest of the Vim interface. Off the top of my head, first ^C is for cancelling actions, second ^C is very close to ^V, which is used for block-select, and very close to ^X, which is used for auto-completion, and very close to ^D, which is page-down, and quitting by mistake would be super frustrating.

I think in this case vi's authors (and by extension vim's author) have picked the right choice of catering to the actual users, rather than being friendly to people who run the editor by mistake. At least they try to tell you "type :quit and press enter to exit".

Re:Helping a Million Developers Exit Vim by dllthomas on Tuesday May 23, 2017 @05:34PM (#14405579)
In both cases, the program doesn't know what you're trying to do. It knows what you're probably trying to do. That's not enough.

In both cases, this is because there's a race condition:

If you run a command and decide you want to kill it, you use ctrl-c. If the command finishes between you deciding to kill the command and the signal being sent, the "container" process (vim or python) receives the ctrl-c. If it always assumes "what you want" is to exit, you've maybe lost work - edits made or variables populated. Avoiding that is definitely the right call!

Re:Helping a Million Developers Exit Vim by theandrewbailey on Tuesday May 23, 2017 @02:11PM (#14403656)
If I expect Ctrl+C to quit immediately, and it doesn't quit immediately, that is not functionality that works.
Re:Helping a Million Developers Exit Vim by adambyrtek on Tuesday May 23, 2017 @03:18PM (#14404299)
You might expect it to quit immediately, but most Vim users don't (for example I have a habit of using Ctrl-C to exit insert mode). When you travel to a foreign country you shouldn't expect everybody to speak your language.
Re:Helping a Million Developers Exit Vim by manyxcxi on Tuesday May 23, 2017 @02:42PM (#14403962)
What if you're normally a Windows user and you pressed CTRL+C trying to copy something out of the terminal? You haven't written to disk in a while, and then poof.

Muscle memory can be a real pain some times.

Re:Helping a Million Developers Exit Vim by noir_lord on Tuesday May 23, 2017 @05:26PM (#14405512)
I got dropped into vim the other day (fortunately I used to be a vim user) unexpectedly.

Had switched from Ubuntu to Fedora and it turns out that vim was the default git editor not nano (until I switched it anyway).

Re:Helping a Million Developers Exit Vim by dsp1234 on Tuesday May 23, 2017 @01:49PM (#14403393)
dev: That just typed ':q' into the text area

me: Hit escape first, then :q

dev: Oh, then why doesn't say escape then :q

me: welp

Re:Helping a Million Developers Exit Vim by dsp1234 on Tuesday May 23, 2017 @01:59PM (#14403511)
Another thing I've seen is the person reads the text as:

"Type: quit<enter> to exit Vim"

Since the colon is used a separator such as I used it above.

Then they type "quit" and enter, which actually put them in insert mode recording "@u", with a 't' sitting in the text area.

Re:Helping a Million Developers Exit Vim by Bartweiss on Tuesday May 23, 2017 @02:50PM (#14404048)
Wait, this is how I got so stuck my first time in vim! It sets you up for a whole string of problems in a row:

- You enter an unfamiliar mode, immediately hit "^c".

- That prompts "Type :quit<enter> to exit Vim".

- You mistakenly type "quit<enter>". So now you're in insert mode with recording, as you said.

- You hit "^c" again, breaking out of insert mode, but you don't get the exit prompt like you did last time - the `recording` message blocks that no matter how much you hit "^c".

- Without the reference message to find your mistake, you maybe try "quit<enter>" again. 'q' now terminates recording, 'u' undoes your typing, and 'i' dumps you back into insert mode, leaving you with a text field of 't' again!

- At this point you maybe hit "^c" again. That'll drop you out of insert, but with text in the field vim no longer prompts you to quit. If you enter "^c" again it will prompt you, but you tried that during recording mode and it did nothing, so you don't expect aimless repetition to help anything!

At this point, you give up, google "quit vim" and discover that the colon was important. I'm pretty sure this madness if what I did the first time git for windows popped open vim as the default editor.

Re:Helping a Million Developers Exit Vim by binarycrusader on Tuesday May 23, 2017 @02:05PM (#14403583)
Except, if you hit Ctrl+C, you don't have to hit ESC. You literally type what it tells you and it works.

The only way the above would work as suggested is if the person hit an insert mode key first after having typed Ctrl+C.

Re:Helping a Million Developers Exit Vim by YeGoblynQueenne on Tuesday May 23, 2017 @03:19PM (#14404304)
Weelll. The problem is that the "quit" command has an insert mode key in it. So it's quite possible to get stuck like a poster above says- enter macro recording, then insert mode, then write the letter "t".

On the other hand that only happens if you type "quit" without the colon and the message makes it very clear that the colon is part of the text you must enter:

  Type  :quit<Enter>  to exit Vim
See all that whitespace? It's very hard to think the colon goes to the "Type" bit.

So you can get stuck in a dubm situation but it's not terribly easy.

Re:Helping a Million Developers Exit Vim by binarycrusader on Wednesday May 24, 2017 @02:09PM (#14412133)
See all that whitespace? It's very hard to think the colon goes to the "Type" bit.

Except, logically, why would they bother to specially call out <Enter>, a whitespace character, but not the spaces as well if they intended the user to type them?

I can't think of any obvious, safe way to display text that a user should type that isn't subject to possible misinterpretation in the single line of output available.

Re:Helping a Million Developers Exit Vim by YeGoblynQueenne on Thursday May 25, 2017 @10:45AM (#14417614)
Alright, but if we're being so scholastic it should be said that you can misinterpret any set of instructions and in this case, squinting at the command line a couple of times to make sure you got the command right is all it should take you to get it right.
Re:Helping a Million Developers Exit Vim by eridius on Tuesday May 23, 2017 @01:56PM (#14403477)
Cute, but no. When you enter insert mode, the "welcome screen" disappears. So if you can see the instruction telling you to type ':quit', then typing :quit will work.
Re:Helping a Million Developers Exit Vim by dsp1234 on Tuesday May 23, 2017 @02:02PM (#14403548)
FTA, https://zgab33vy595fw5zq-zippykid.netdna-ssl.com/wp-content/...

It happens because people don't what they are doing. You assume that they hit ctrl+c, then immediately type :quit, but if they did, then they wouldn't be Googling it. They did something between trying to exit and quit that got them into a different mode.

Re:Helping a Million Developers Exit Vim by eridius on Tuesday May 23, 2017 @02:18PM (#14403729)
I'm not assuming they're hitting Ctrl+C.

What I'm saying is the screen that says

                               VIM - Vi IMproved                                
                                                                                
                                version 8.0.567                                 
                            by Bram Moolenaar et al.                            
                  Vim is open source and freely distributable                   
                                                                                
                            Sponsor Vim development!                            
                 type  :help sponsor<Enter>    for information                  
                                                                                
                 type  :q<Enter>               to exit                          
                 type  :help<Enter>  or  <F1>  for on-line help                 
                 type  :help macvim<Enter>     for MacVim help
disappears as soon as you enter insert mode (or really interact with Vim at all). If you're in insert mode, you don't see this. So if you see this, typing :quit will work.
Re:Helping a Million Developers Exit Vim by dsp1234 on Tuesday May 23, 2017 @02:32PM (#14403872)
Of course, yes. The above commenter mentioned insert mode and ctrl+c which is why I was missing that you particularly were talking about this one screen.
Re:Helping a Million Developers Exit Vim by FreeFull on Tuesday May 23, 2017 @02:08PM (#14403632)
Perhaps they miss the : Without it, you end up recording a macro and going into insert mode.
Re:Helping a Million Developers Exit Vim by StavrosK on Tuesday May 23, 2017 @02:10PM (#14403640)
Even if you're in insert mode, ctrl-c takes you to normal mode, then a second press will show you the hint.
Re:Helping a Million Developers Exit Vim by a3n on Tuesday May 23, 2017 @01:57PM (#14403486)
vim myfile.txt opens myfile.txt, and literally does not show the splash screen.
Re:Helping a Million Developers Exit Vim by masklinn on Tuesday May 23, 2017 @02:00PM (#14403524)
And worse vim is often the default EDITOR or software's fallback in case no EDITOR is set, so you get dropped into a vim edition buffer seemingly randomly.
Re:Helping a Million Developers Exit Vim by fishywang on Tuesday May 23, 2017 @02:06PM (#14403605)
I'm pretty sure that I've never seen any OS/Linux distribution set default EDITOR to vim. If EDITOR is set to vim, then someone must intentionally did that.
Re:Helping a Million Developers Exit Vim by slrz on Tuesday May 23, 2017 @02:51PM (#14404057)
Right. Many programs react to an unset EDITOR variable by assuming vi though. This makes sense, of course, as virtually all systems are going to have some implementation of vi installed. Even the almighty ed tends to be missing from the default install of some recent Linux distributions.
Re:Helping a Million Developers Exit Vim by JdeBP on Friday May 26, 2017 @01:12PM (#14425634)
Only if they have wrongly conflated EDITOR and VISUAL.
Re:Helping a Million Developers Exit Vim by YeGoblynQueenne on Tuesday May 23, 2017 @03:24PM (#14404373)
That's probably out of mercy- saves people from getting stuck in ed.
Re:Helping a Million Developers Exit Vim by dsp1234 on Tuesday May 23, 2017 @02:10PM (#14403653)
git bash on windows has vim as the default editor when editing commit messages
Re:Helping a Million Developers Exit Vim by fishywang on Tuesday May 23, 2017 @02:14PM (#14403691)
Maybe someone should file a bug to them? I don't think vim is a sane default value for EDITOR, but I have no idea whether there's any sane alternative on Windows.
Re:Helping a Million Developers Exit Vim by hepek on Tuesday May 23, 2017 @02:48PM (#14404037)
I believe POSIX defines vi as mandatory visual text editor, which makes it present on any compliant OS and thus a sane default value for EDITOR.
Re:Helping a Million Developers Exit Vim by masklinn on Tuesday May 23, 2017 @04:00PM (#14404727)
Technically it's part of the optional "User Portability Utilities" feature group, and so is ex, the only mandatory editor in POSIX is "ed".
Re:Helping a Million Developers Exit Vim by xxs on Tuesday May 23, 2017 @02:42PM (#14403963)
'nano' is fine
Re:Helping a Million Developers Exit Vim by simopaa on Tuesday May 23, 2017 @02:39PM (#14403945)
I switched to nano recently, and it wasn't as easy as it perhaps should have been: https://stackoverflow.com/questions/36802996/bash-nano-comma...
Re:Helping a Million Developers Exit Vim by throwaway2016a on Tuesday May 23, 2017 @03:31PM (#14404439)
In OS X it is vim.
Re:Helping a Million Developers Exit Vim by theandrewbailey on Tuesday May 23, 2017 @02:08PM (#14403630)
That's the point. That behavior is contrary to the expectation. Ctrl+C should not display a message: Ctrl+C should quit immediately.
Re:Helping a Million Developers Exit Vim by brewdad on Tuesday May 23, 2017 @02:13PM (#14403684)
Coming from the Windows world, I am happy that Ctrl+C doesn't make assumptions and quit. Imagine attempting to copy something and having your file close without warning.
Re:Helping a Million Developers Exit Vim by ygra on Tuesday May 23, 2017 @02:53PM (#14404078)
You can intercept Ctrl+C on Windows just as well and do nothing, or something different than quitting.
Re:Helping a Million Developers Exit Vim by smoe on Tuesday May 23, 2017 @02:23PM (#14403774)
How many interactive programs actually close immediately if you hit CTRL+C? Why would you expect that of vim?

If nano were the editor you end up in, you would have the same problem.

Re:Helping a Million Developers Exit Vim by falcolas on Tuesday May 23, 2017 @02:23PM (#14403773)
Here's the problem: Ctrl-C isn't quit. It's keyboard interrupt, and that does not necessarily mean "quit".
Re:Helping a Million Developers Exit Vim by JdeBP on Friday May 26, 2017 @01:17PM (#14425666)
Ironically, in vim, where the terminal is in non-canonical input mode when vim is in the foreground, it is not keyboard interrupt. (Nor is it in most modern shells, which also use non-canonical input mode in their command line editing mechanisms.)
Re:Helping a Million Developers Exit Vim by bryanlarsen on Tuesday May 23, 2017 @02:12PM (#14403671)
On many editors ctrl-c is the copy key. Not a good key to exit on...
Re:Helping a Million Developers Exit Vim by kpil on Tuesday May 23, 2017 @02:35PM (#14403905)
It's the other way around - mapping copy to ctrl-c was a bit stupid...
Re:Helping a Million Developers Exit Vim by slrz on Tuesday May 23, 2017 @02:56PM (#14404097)
Yep. Apple got this one right with the Cmd key. Much saner than the context-dependent hijacking of the control key with its long-established conventional usage.
Re:Helping a Million Developers Exit Vim by bryanlarsen on Tuesday May 23, 2017 @04:07PM (#14404790)
Very true, but that argument was lost over 20 years ago.
Re:Helping a Million Developers Exit Vim by chrisweekly on Tuesday May 23, 2017 @02:55PM (#14404089)
CTL-C, or CMD-C?