On Saturday, April 11, 2015 at 10:30:27 AM UTC+5:30, Yuri wrote: > Once in a while I get into this after accidentally typing the wrong command: > # vim some-file | some-cmd > bash: some-cmd: command not found > Vim: Warning: Output is not to a terminal > ^C > > Ctrl-C doesn't kill vim. So I have to press Ctrl-Z and then have to > either 'killall vim', or trying to determine what is the pid of vim to kill. > Is there any way to make it just die on Ctrl-C in such situation?
Not really, if the pipe makes vim run 'in background' and having no normal connection to the terminal, it can not be informed about the ^C. As long as ONLY THE OUTPUT IS 'invisible', but the input still is from the terminal, you can end vim normally by ':qa!' BUT you need to hit <Ctrl-J> (real 'Newline'), not some Return- or Enter-Key, because there is no mapping then. So simply hitting exactly ":qa!<Ctrl-J>" (not the ") ends vim correctly. In my test, if needing Ctr-Z too, I could run 'jobs -l' to show the stopped 'job' (therein vim), and simply kill vim by pid number. Dependig on how the shell created the pipe, the shell is still the parent of that vim, then it's 'parent process' would be the process id of the shell i.e. The numbber in '$$'. If your shell has only the ONE vim as child, you might be able to write a script to kill such a vim automagically. (e.g. search by 'pstree -p $$' or simply by piping "jobs -l | vim_kill_script", then finding the children of the shell, check for 'vim's pid and kill it. Stucki -- Christoph von Stuckrad * * | also XMPP = |Mail <[email protected]> \ Freie Universitaet Berlin |/_*| 'jabber' via|Tel(Mo.,Mi.):+49 30 838-75 459| IT Mathematik & Informatik|\ *|stucki@jabber| (Di,Do,Fr):+49 30 77 39 6600| Takustr. 9 / 14195 Berlin * * |.fu-berlin.de|Fax(home): +49 30 77 39 6601/ -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
