28 ms·
How to Exit Vim
- thrwaway69 7y agopssh.. they didn't mention the vimtectualist way - :q! or the French way - ZZ
- justinzollars 7y agocreate a pull request
- slim 7y agothe french way :D
- kranner 7y agoThese would ruin the joke.
- thrwaway69 7y agoyeah, I was poking at the joke :)
- jraph 7y agoAs a vim noob, I needed to look it up [0]. ZZ saves the current file if modified and closes it. ZQ closes it without saving. Thank you, that will save me a few seconds per year. Why the French way? I don't get it and I am very curious :-) [0] https://unix.stackexchange.com/questions/93144/exit-vim-more-quickly https://unix.stackexchange.com/questions/93144/exit-vim-more...
- lgeorget 7y agoMaybe because of our (I very much include myself) infamous inability to pronounce correctly the sound "th" and making it sound like "z" instead.
- jraph 7y agoAh yes, zis is it. Fank you.
- Arrrlex 7y agoI'd have thought it's because the French keyboard layout is arranged with the "Z" in place of the "W" on a qwerty layout
- throwaway744678 7y ago(Wild guess) If you pronounce the command aloud - "Zee-zee" - it translates to "Willy" (penis word used by children) in French. Easy mnemonic.
- toby- 7y ago>Zee-zee Only if you're American. Otherwise: "zed-zed". :)
- mike_hock 7y ago> or the French way - ZZ HOW DID I NOT KNOW THIS
- Lex-2008 7y agoI like The timeout way :-)
- hyperpallium 7y agovimperil
- eoikonomou 7y agoActually the random timeout is even better!
- thepete2 7y agoI have the feeling something is missing on that list, but I can't put my finger on it ...
- mihaaly 7y agoI think it's the Hulk way. I seriously considered the Hulk way the first time. (since then I implemented the preemptive way: never ever try to open it again)
- Zenst 7y agoBRS, that old classic Big Red Switch, kills all known operating systems and proc's, dead in their tracks. Me, It's usually :wq, or sometimes :q! or more than likely ZZ - which can be done with shift zz or if you truly want to do it with just one finger, capslock then zz.
- xerox13ster 7y ago:x
- epr 7y agoThank you. I swear every time I see a tutorial where someone is using vim they say to save and close with :wq and it drives me nuts.
- Zenst 7y agoThat is because it is easier to teach as x you will associate with exit, though wq is write quite, but more so if you just want to save without exit you logically understand to just use w and from that you start to think - could I do :q, why yes you can if nothing changed and if so it will tell you. But stressing how people exit vi is like stressing about people's fashion, just not worth it. If anything, have a private laugh at them to yourself and use that to remove other stress as more than enough stress in life, more so IT without seeking it out.
- a3n 7y ago
- winrid 7y agoEdit - Related in that I used vim and probably won't again: I recently did an interview where I had to implement something to flatten a deeply nested structure into a map of path -> value. The interviewee's had me use VIM. That was my first real dive into it. Solved the problem, already forget how to use VIM. :)
- DonHopkins 7y agoThe only vi command I know is :q! (That and the Rogue navigation keys.)
- pantulis 7y agoBonus geezer points for calling them Rogue navigation keys instead of NetHack navigation keys.
- mikro2nd 7y agoIf my ageing memory serves, it was the other way around: Rogue imitated vi for navigation keys.
- suprfnk 7y agoDon't both originate from the fact that (some) early keyboards had the arrow keys on HJKL? https://stackoverflow.com/a/29243081/1891877 https://stackoverflow.com/a/29243081/1891877
- eddhead 7y agoOh looks, it's only been 10 minutes since the last Vim article was trending on HN, we're rivalling Hollywood levels of bubble here. Seriously, when CES is currently showing hundreds of new tech products and services, including a Hyundai electric helicopter - Vim is what we still talk about?
- scarejunba 7y agoBe the change you want to see in the world, bruv
- zelly 7y agoit's called hacker news, not electrical engineer news, not startups news
- eddhead 7y agoIt's on YCombinator, which is a startup accelerator
- dkersten 7y agoYes, but it’s never been just about startups or business. It’s always been any topic of interest to hacker types which includes startups and business, but also technology, programming, tools, peoples projects and even sometimes satire of such.
- layoutIfNeeded 7y agoCES hasn’t been relevant in the past decade. Why would we care?
- eddhead 7y ago> CES hasn’t been relevant in the past decade. Why would we care? And Vim is? When there are editors like VS Code?
- 7y ago
- scanr 7y agoI like :x which effectively does an :wq if there have been changes but is one character less.
- tgv 7y agoZZ
- dotandimet 7y agoBut these just close the current window, not the entire program
- k4ch0w 7y agoIt also prevents the modification time from being changed after closing the file, if no changes were made.
- NalNezumi 7y agoThey forgot the Freshman CS student way: Panic, Lock the computer in the computer room, run.
- vermilingua 7y agoSend a PR!
- acje 7y agoFrom the readme: "Remotely: $ while true; do curl http://vi-host:8888/kill-vi-$RANDOM; http://vi-host:8888/kill-vi-$RANDOM; done vi will eventually exit" Bold claim, and how would you know? What if there is a network partition preventing you from getting the message that exiting vi failed and Chuck Norris?
- jrumbut 7y agoAh, the famous CEVP Theorem (Consistently Exiting Vim under Partition). Almost as important a problem in Computer Science as P!=:WQ.
- cynwoody 7y agoI just do ZZ, if I want to save the buffer, or ZQ if I was just looking, or I messed up (I'm a vim newbie).
- suprfnk 7y agoThis page is satire. :)
- z92 7y agoThis one is the shortest way in the list : The test driven development way :echom test_null_list() And it works. Just checked.
- gpvos 7y agoDoesn't work for me, just gives an error message "E730: Using List as a String" and returns me to command mode.
- raverbashing 7y agoUse nvim, press Ctrl-C and it will show the corresponding help message
- CGamesPlay 7y agoIt is not necessary to use nvim to see this help message; it's in vim 8.0 that comes stock with my Mac.
- raverbashing 7y agoTrue, I just checked, though the help message is a bit different
- huhtenberg 7y agoWhere's fun in that?
- weinzierl 7y agoThe question is not "How" but "Why" you would want to ever do that in the first place;-) Many years ago I knew a university professor and students said about him he might leave uni occasionally but he sure never leaves Emacs. Some live in Emacs, some live in Vim.
- cmroanirgo 7y agoI live in a different universe to you it seems. The only vim command I know is :q. Honestly, I tried several times over the decades and walked away with my head buzzing. PS: I don't live in emacs either! What I do love in both camps is how the explanations begin... "All you have to do is...[insert irrational (to non-vim/emacs users) command]" which makes me laugh every time. Love the article, which ironically proves my stance of me keeping well clear.
- deleted 7y ago[deleted]
- Cthulhu_ 7y agoI know some basic commands and know it well enough to edit git commit messages and interactive rebase (`ddkP` is probably the most advanced command I know). But I've never thought "I prefer this over my regular editor this is amazing". I just don't get the satisfaction. And of course I'd have to dive deep into the ecosystem in order to get the same benefits that my main editor provides out of the box, like idk, cmd+click to go to definition, or error reporting like squiggly red lines.
- yodsanklai 7y ago> And of course I'd have to dive deep into the ecosystem in order to get the same benefits that my main editor provides out of the box, To me, vim shines as a modal editor, not an IDE. I use it for two purpose: 1. quick editing configuration files, or single file scripts 2. an editing mode in an IDE (mostly VSCode) The main benefit of vim is to save you from using the mouse or the touch pad. I touch type, my indexes rest on F and J, and I can do pretty much anything without leaving the keyboard, without using the arrow keys, and keeping my eyes on the screen. It's not something I'd know how to do without Vim. If I'm using the arrow keys, I need extra-time to relocate the "J" key, which breaks the typing flow.
- yoz-y 7y agoI came into this with a sense of "oh not again" and came out surprisingly happy. TIL that ZZ, ZQ exist and that a disown command exist on the command line. Also my preferred method from the list is the timeout, it would be nice to have counter in a corner of the vim window to know how much time is left though.
- mewpmewp2 7y agoWhat I do is I set a 25 min timeout, so not only it exits vim it also acts as a Pomodoro timer for me. Two birds, one stone.
- smcl 7y agoIt's amazing to think how far we've come since June 2018 where the record was just shy of three minutes (https://www.youtube.com/watch?v=TLbfqZBL8t8 https://www.youtube.com/watch?v=TLbfqZBL8t8). These new strategies could allow experienced speedrunners to exit vim in times of 10 seconds (or perhaps less!?). I'm excited to see how this progresses, the vim speedrun community is vibrant and creative and I've no doubt we'll see a sub 5-second run within my lifetime.
- Dowwie 7y agoI believe the solution to this lies in using Rust and SIMD. It will achieve both performance and safety.
- bobowzki 7y agoI would prefer a functional approach and formal verification so we can know for sure it will exit.
- aargh_aargh 7y agoSince the real world is not necessarily deterministic as demonstrated by the methods using random(), I hope to see more development in stochastical methods describing parameters of probability distributions of successful exits.
- nurettin 7y agoIn the face of vim's unyielding resilience to exiting, I think we may need to devise a new algorithm for this using quantum superposition. I heard IBM can help with that.
- Dowwie 7y agoBut who would support it? While a formally verified functional approach may satisfy one's doctorate requirements, the author will graduate and move onto blockchain development, leaving behind an exit-vim code base that no other engineer could possibly understand without the equivalent training. Upon receiving said training, an engineer would also take newly acquired doctorate and also move onto blockchain development. Essentially, supporting a formally verified functional approach to exiting Vim creates a pipeline of well-credentialed and rigorously trained professionals for blockchain development. If Vim were, however, put on the blockchain, we may be able to address this concern and you can get what you wanted. Or, you could have just used Rust and SIMD.
- namelosw 7y ago- So, how did you learn Vim? I heard there's quite a learning curve. - I just open it, but I couldn't figure out how to quit. Then I have been using it for three years already. (Same applies to Emacs.)
- elfexec 7y ago> - So, how did you learn Vim? I heard there's quite a learning curve. You can go through the interactive vimtutor. Type :help tutor Or you can just type :help and find the link to the vimtutor. If you are using gVim, then it should be one of the menu items ( maybe under help? ). My suggestion is to just search for basic vim cheat sheet if you are getting started. There are also youtube tutorials online. Sometimes watching someone work with vim can help you get over the hump. > - I just open it, but I couldn't figure out how to quit. :q to quit. :q! to quit without saving. Remember to hit ESC to get back to the normal mode first if you are in other modes. When you are comfortable with Vim then you can go on to some of the advanced vim topics. Also, in the beginning you might have to ddg/google/etc a bit. Good luck.
- kburman 7y agoI have tried to start using vim so many times and failed. Even this year I thought to start using vim. Daily I open vim once try to do something new with it. Although I don't have much of hope that I will start using it an soon.
- kshacker 7y agoI first used vi / vim about 30 years back. There are other editors that provide fancy features and I do use them routinely but there is no day I have not started (and exited) vim. Get used to it.
- Grimm665 7y agoAs a sysadmin, not a programmer, what I found helpful for learning Vim was not to try something new each day, but to find one or two commands that were valuable enough that I would at least open Vim somewhat regularly. The two that did it for me are delete line (dd), and change inner word (ciw), both extremely helpful for config file editing, especially when combined with repeat command (.) After learning these first simple commands, it was enough to get me to open Vim at least a few times a day, which then motivated me to start learning more of the commands and it just snowballed along. I still only know probably 25% of Vim, but I feel incredibly comfortable in it now and rarely run into trouble when doing beginner to intermediate editing tasks.
- techbio 7y agoJust stay in Vim :)
- unkulunkulu 7y agoYou could send a PR with an “Acceptance way”. Also there’s “Radical acceptance way”: kill every other process, although I’m from mobile and too lazy to work out an exact shell command for that
- kibibyte 7y agoI know this is humor, but I never knew about using Ctrl+R (<C-r>) within insert mode or within an Ex command.
- globuous 7y agoFun read! My next bash exercise will be to try and understand some of these commands, quite a feat! greping the ps output would work with any program, right ? That was pretty cool. Killing it from emacs was def a good laugh ! They should add the script kiddie way: `sudo rm -rf /` ^^
- inimino 7y agoThat might delete the executable but the process would still be running. Yep, `ps | grep` is a common and useful idiom!
- ktpsns 7y agoIn fact "pkill init" or "kill 0" (each with sudo/root privileges executed) will most likely kill all processes and is some kind of process equivalent to delete all files ;-)
- al_be_back 7y agosafe-rm voids that command ( https://launchpad.net/safe-rm https://launchpad.net/safe-rm )
- reacweb 7y agoI do not like the grep -v grep pattern. I think the regexp trick should be prefered: :!ps axuw | grep [v]im | awk '{print $2}' | xargs kill -9 This can also be merged in the awk command: :!ps axuw | awk '/[v]im/{print $2}' | xargs kill -9
- wadkar 7y agoUgh, ps|grep is unnecessary. Just use pgrep! Or even better, pkill -9 ;-)
- xorcist 7y agopgrep is a good habit, it's on every major unix except perhaps aix. Most other constructions can backfire in some unexpected way.
- JdeBP 7y agoNext you'll be telling people to use SIGHUP instead of SIGKILL. Or to use the PID. Or to get VIM to substitute its own PID into the ex command using getpid(). * https://mywiki.wooledge.org/ProcessManagement#The_risk_of_parsing_the_process_tree https://mywiki.wooledge.org/ProcessManagement#The_risk_of_pa...
- JdeBP 7y agoIssue 26 (q.v.) is closed.
- cptnapalm 7y agoI started using Linux in 1997 and just today I've found out about pgrep and, on reddit, sudo !! What a day!
- wadkar 7y agoWow! Glad to be part of your journey in discovering linux. I have been amazed by linux since my teenager years and it still has so much more to offer. May we be blessed to be amazed for the eternities of our mortal lives.
- deleted 7y ago[deleted]
- shrimpx 7y agoI got one: stop paying the electric bill.
- teekert 7y agoI just installed a Kasa TP-Link smart plug, now I can kill Vim from an app!
- GavinAnderegg 7y agoOn a saved buffer, I usually use `Ctrl-w q` (Window command, close). I have Ctrl mapped to caps lock, so this is super quick to do with one hand.
- teekert 7y agoJust close the terminal window en delete all files starting with ~ in the directory. Very clean way to stop Vim.
- SpaceInvader 7y agoHow about the most basic? ;-) q! wq! x! ;-)
- rushi_agrawal 7y agoDidn't see a mention of a very fast way of exiting Vim, so sharing: 'The iTerm way': map cmd-l to send a hex code '0x6A 0x6B 0x3A 0x71 0x0D' (translates to jk:q<enter>, where jk is my Vim binding to get out of insert mode) For me, just like any other touch typer, left thumb is always on cmd and right ring finger is always on 'l' key, so this arrangement takes least amount of time for me to quit Vim.
- mlvljr 7y agoToo hard, Givin up.
- gpmcadam 7y agoOh dear. What are the chances this will eventually rank fairly highly on search engines - this is going to ruin the soul of the unsuspecting people who end up thinking that this is not satirical advice.
- jerzyt 7y agoIf you don't see it's a joke, Vim is not for you. Stick with Notepad or Google Docs. Obviously, it's not aimed at you :-;
- gpmcadam 7y agoTo clarify, if someone gets stuck in 'vim' when debugging an issue and searches the web for "how to exit vim" and ends up on the document linked in the OP ... your advice is "stick with Notepad"?
- Zenst 7y agoBetter they ruin their own soul than inflict upon others is the way to look at that. But then, what type of people don't RTFM besides the whole generation that treat google as their manual and when the internets down, so is there `knowledge` /s.
- cerebellum42 7y agoRTFM clearly does not apply because you can't read it if you're in vim and can't exit ;)
- Zenst 7y ago:h or failing that, the tried and trusted :!man vim Though I'm wondering how many have discovered the first one with some frantic help me after typing the : and got there by accident. Oh you can apparently just hit F1 in vim, wow.
- smitty1e 7y agoI would add a Paul Simon way, loading "50 Ways To Leave Your Lover" until resources are exhausted.
- al_be_back 7y agoone could use emacs instead - it's a sure way to exit vim ... :\ :/
- lsiebert 7y agoAs I sit here, vim running for several months inside an nvim terminal inside a tmux window inside an iterm tab inside mac os x, I think the real question is, why exit vim yourself when you can Inception vim's creator to do it for you? That, as many people know, is actually how vim finally became threaded, and I'm sure it could be used to make a code change that exits vim automatically. Then you only have the task of modifying your vim executable in memory as well as on disk, which is so trivial that I leave it as an exercise to the reader.
- brutt 7y agoFirst step to quit vim is to accept that you are vim user. Here are some tips: Try to limit yourself to one vim session per day, then one session per week, and so on. Try to replace some Vim sessions with Emacs. Buy notebook with keyboard without Esc key. Install an OS without Vim. Use mouse.
- hawaiian 7y ago> Try to replace some Vim sessions with Emacs. I thought you said quit Vim, not go running back into its warm embrace.
- JadeNB 7y ago> Install an OS without Vim. The hardest of the steps ….
- joncp 7y ago> use mouse Noooooo! Not that! Please not that!
- JdeBP 7y agoWhy not? It works with VIM and NeoVIM. (-:
- jimbokun 7y ago"Buy notebook with keyboard without Esc key." So now we see what Apple was trying to accomplish with the Touch Bar.
- swiley 7y ago>Use mouse. OMG I use pretty much the default settings in vim but set mouse= is one of the only 2-3 things I put in my vimrc! The macbook pro and old thinkpads are the only laptop computers with decent built-in pointing devices, all the others always end up coupling with my palms and randomly munging my code!
- bcrosby95 7y ago> Try to replace some Vim sessions with Emacs. Done because I love org mode. What's that? Evil mode? Nah. That's nothin. Ignore it.
- bigbaguette 7y agoThis post is perfect to spot people who comment without reading the source. :q
- JdeBP 7y agoSeveral comments here have merely duplicated old closed issues. * https://github.com/hakluke/how-to-exit-vim/issues/14 https://github.com/hakluke/how-to-exit-vim/issues/14
- bachmeier 7y agoThe Russian Roulette timeout way brings back memories of Windows 98.
- hellofunk 7y agoI think the more interesting question is, after you eventually exit vim, what do you do next? The best advice I ever received was, you next open emacs and leave the session running the rest of your life.
- cmarschner 7y agoAre you using tabs as well?
- 29athrowaway 7y agoThe 1st example could be simpler using pgrep and cut, or simply pkill or killall. You can also just suspend it (ctrl+Z), and resume it with fg.
- oefrha 7y agoAs an Emacs user I just realized to my horror that I know the command(s) to exit vim but not the one(s) to exit Emacs. I can only tell you it begins with C-x. (Of course, my left hand knows.)
- topologistics 7y agoSometimes your right brain doesn't have to know what your left hand is doing.
- lelf 7y agoIf exiting vim is too easy, try the advanced level: exiting "vim -y".
- iso1210 7y agoWow, that's an evil mode. Man says it's the "easy" mode.
- Lio 7y agoTry Ctrl-o followed by :q! That should do it. ;) Ctrl-o moves from INSERT mode to COMMAND mode for one command and so it still works in "easy" mode. I notice that "easy" mode was one of the things that the Nvim guys removed.
- gingerlime 7y agoThis is so fun. Reminds me of Nocode[0] [0] https://github.com/kelseyhightower/nocode https://github.com/kelseyhightower/nocode
- numlock86 7y agoI like this commit: https://github.com/kelseyhightower/nocode/commit/80f38e0f103487fc37d853a98a580c67b4db7b55 https://github.com/kelseyhightower/nocode/commit/80f38e0f103...
- brazzledazzle 7y agoI distinctly remember being a teenager and trying vim. Being entirely confused I wanted to exit and when I realized I couldn't I panicked a bit and started smashing keys. Eventually I gave up and forced a reboot with the power button. Based on my extensive experience with Windows I was confident it was hung in a bad state.
- jerzyt 7y agoI once found a system where a third party vendor installed vim as root with suid permissions. I've had a few days of fun before I finally decided to clue the sysadmin about it.
- jerzyt 7y agoInterestingly, deleting the vim executable won't exit, because Unix has the "funny" habit of keeping a file handle alive as long as it's referenced by a process. Really cool way to mess with some noobs.
- samatman 7y agoWhat is the 'deleting an executable' you speak of? All I know how to do is remove a reference to a file, and hope it's the last one and that Unix will garbage collect it eventually. Remember kids: `rm` is just `ln` backwards.
- srik 7y agoAtleast this ones a bit amusing. Speaking of amusing, this book on the vim website - https://www.vim.org/images/exiting_vim.jpg https://www.vim.org/images/exiting_vim.jpg
- yason 7y agoIn the opposing vein, as an Emacs user the best configuration I ever made was to rebind C-x C-c to execute-extended-command instead of kill-emacs. It was way too easy to (even accidentally!) kill emacs with a sweep of a finger. And I probably use a few hundred execute-extended-command calls for each kill-emacs (which I now have to type manually as 'C-x C-c kill-emacs' - no problemo). A similar optimisation was with tmux to bind the prefix to C-z. It's in a handy location next to ctrl and I very rarely use suspend anyway (which is still available as easily as C-z z). Stretching your fingers between ctrl and b (the default prefix key) merely made me wonder who the heck thought of something like this? As for vi, I made a point of learning to use it enough to do useful work editing config files and small texts. Every once in a while another application brought up 'vi' for some reason (maybe I lost VISUAL or EDITOR while sudoing or the app was looking for another variable) and I could never exit the damn thing. So instead of just learning :q and figuring out how to make the particular program or script relaunch another editor I thought it's the path of least resistance to just edit with vi directly. It has been an incredibly handy skill: I never use vi for anything larger but these days I actually do 'vi /etc/fstab' myself instead of calling for emacsclient. However, I've been toying around with the idea of eventually writing a minimal 'vi' clone that you cannot exit. I'm sure there's pent-up demand just waiting for one!
- anotheryou 7y agoI think emacs is the winner here. It's true beauty is that most users have remapped everything so all you can do is bruteforce your way to the exit. And where do you get exiting an OS? We don't know... maybe another OS...
- dan-robertson 7y agoUsually people don’t remap the menus much so I think if you clicked around the modeline enough you could pull up some help and eventually figure out the binding for kill-emacs or execute-extended-command.
- wffurr 7y agoHow do you exit, then, if you never learned :q?
- joantune 7y agoI can't wait for this article to be on top of Google's search results for 'how to exit vim' = D
- mlang23 7y agoThe BRLTTY way: 1. $ echo ZZ | brltty-clip -r 2. Switch to Vim and invoke the paste command of BRLTTY.
- ludwigvan 7y agoEasiest way for me is ESC (just to be sure we are not in insert mode), followed by `ZZ`. (`ZQ` if you don't want to save)
- chvid 7y agoGreat jokes but bad user interface design comes at a real cost.
- jmiskovic 7y agoFrom perspective of ASCII-only application, vim interface isn't actually bad, it just lacks discoverability. There is also a real cost to making tool beginner-friendly and it often makes sense to optimize for advanced users instead.
- noisem4ker 7y agoAn interface lacking discoverability is a bad interface.
- jmiskovic 7y agoOnce you learn the tool, discoverability wastes screen space and user focus. It's like training wheels, at some point you want them off or they slow you down. I'm not a vim user, I just appreciate the UI trade-offs made by its devs.
- noisem4ker 7y agoAt that point, you should be able to hide the parts of its interface that you no longer need. Defaulting to an optimized, non-discoverable setup from the start is simply a bad idea.
- akho 7y agoVim interface is copied too often for you to call it bad. It’s obviously well-loved.
- chvid 7y agoNo. It is quite objectively bad ui. That thousands of users cannot figure out how to do basic things is as objective as it gets. Also that we nerds enjoy making jokes about it instead of fixing it is the reason we don't get invited to parties.
- tinti 7y agoI would love to see a HowToBasic way (https://en.wikipedia.org/wiki/HowToBasic https://en.wikipedia.org/wiki/HowToBasic).
- tomcam 7y agohttps://howtoexitthevimeditor.com/ https://howtoexitthevimeditor.com/
- numlock86 7y agoI was on a remote system and remember I couldn't exit vi. What did I do? Well, I opened a second ssh session, looked up the process id with ps and killed it. This is so many decades ago ... like the very beginning of my curiosity when it comes to IT basically. Thinking back to it, I wonder how I was able to use ssh and tools like grep, ps and kill but did not know how to operate basic vi ...
- Kye 7y agoI did similar with early desktop Linux. vim opened up in one of the ttys, and I couldn't figure out how to close it, so I hopped to another tty and killed it.
- noxToken 7y ago>Thinking back to it, I wonder how I was able to use ssh and tools like grep, ps and kill but did not know how to operate basic vi ... This has become a recurring thing for me to the point where I sometimes feel like I'm not as intelligent as I used to be. I'll need to look at requirements around older existing code, so I use git blame to see the commit history. It occasionally leads to me to some older code that I had written, and sometimes I marvel at how I was able to figure out or troubleshoot the issue. One of the earliest examples in my professional career is using Threads. I had an academic understanding of threads. My practical knowledge around them was dubious at best. With the help of Stack Overflow and lots of web searching, I cobbled together a thread manager that can spawn separate threads for asynchronous web requests and kill a web request after X amount of time. I even made sure that error handling redirected gracefully should one of those threads get killed. That code (with no changes to the core functionality) still exists to this day.
- ArcMex 7y agoHow to exit vim big brain style with all changes saved in memory. :q! your memory, not the computer's
- makach 7y agoI thought it was a joke article until I realized it wasn't
- joeraut 7y agoOne of my Computer Science lecturers had a rule: use Vim for all development for his class whilst on campus, and if caught using any other editor/IDE – or committing any artifacts showing evidence of such – we would lose several percentage points from our final mark for his class. Harsh? Perhaps. But I can’t thank that lecturer enough for that rule. He converted a mostly IDE-wielding class into one that actually appreciated Vim, and most of us still use it or its key bindings. Edit: this was in 2018, when VS Code, etc. were already popular.
- hwestiii 7y agoThis is more or less what I did, but under my own motivation. I charged myself to do all my CS homework in vi and had a copy of O'Reilly's Linux in a Nutshell at my side. It didn't take more than a couple of semesters and I didn't need the book at all.
- manmademagic 7y agoHad the same thing when I was studying CompSci. Ended up spending more time configuring vim than doing the work I was supposed to do. Even did the completely pointless exercise of making custom syntax highlighting for the pseudocode language we had to use.
- joncrane 7y agoThis prepared you for the 'real world' better than any programming lessons could!
- Aperocky 7y agoOnce configured vim works fine. I probably spend 1-2 hour/day in vim for my personal projects but haven’t configured anything in months.
- manmademagic 7y agoI think I had most things working properly within the first few days, but kept customizing and changing settings/fonts/themes/plugins. Mostly procrastinating by pretending I was "Being Productive"
- forgotmypw_ 7y ago^Z
- astatine 7y agoThis is a well studied problem from the days of Turing. Named slightly differently as the Halting Problem, the question of whether Vim will stop for a given arbitrary input has been proven by Turing [https://en.m.wikipedia.org/wiki/Halting_problem https://en.m.wikipedia.org/wiki/Halting_problem] to be unsolvable.
- AnnoyingSwede 7y agoI just wish i could upvote this more! :) Love the Jira way!
- talles 7y agoJokes aside, shouldn't the page start with actually teaching how to quit vim? The page is considerably popular to show up on a Google search. I imagine the frustration of a beginner actually trying the first examples and not getting the joke immediately.
- petepete 7y agoI'd bet that most people who get stuck don't start vim themselves though. I taught (the basics of) git to a bunch of students recently and the first time we did a commit I had to go around the room and show people how to operate vim. I bet the same happens when new people use visudo, etc
- noisem4ker 7y agoThis is why vim is a bad default. Thankfully, there's someone thinking about changing this [0]. [0] https://www.phoronix.com/scan.php?page=news_item&px=Fedora-Workstation-Vi-To-Nano https://www.phoronix.com/scan.php?page=news_item&px=Fedora-W...
- kungtotte 7y agoI don't know about vim, but in neovim you're greeted by the following when you launch it the first time: type :help nvim<Enter> if you are new! type :checkhealth<Enter> to optimize Nvim type :q<Enter> to exit type :help<Enter> for help This joke is pretty outdated :P (But still kind of funny)
- DarkWiiPlayer 7y agoYou get the same thing in vim, but only when you open it without a file. Chances are, you only do that when you're already a vim user, and most non-users will be confronted with any random program opening a file in vim for them to edit (visudo, git commit, etc.)
- thaumasiotes 7y agogit will open pico if you haven't configured an editor. It's annoying. If you have configured an editor, hopefully you already know how to quit.
- buboard 7y agoI just don't understand why anyone would want to exit vim.
- franze 7y agoThe Scrum manager way 1. Call in a meeting, early in the morning 2. Tell everybody what a good job they are doing. 3. Tell everybody that there is still a lot to do. 4. Tell everybody that "we" can do it. 5. Remind them of the importance of team work. 6. Go through the tickets. 7. Tell the project manager that a ticket for closing Vim is missing. 8. Write a ticket called "As a user I want to exit Vim!" on your own. 8.1. While reminding everybody that this is not the proper process. 9. Discuss new ticket in group. 10. Reword ticket as "As a user I want to be able to open other applications!" 11. Ask who of the team wants to do this. 12. Postpone decision until the next meeting.
- time0ut 7y agoThere is a step somewhere in there where we waste 30 minutes playing "agile poker" and arguing about the number of story points required to close vim. The whole thing is followed up with a two hour retrospective where we pat ourselves on the back for increasing velocity (due to assigning story points to closing vim). Bonus points if you then are asked to map that back to actual hours so we can estimate completely unrelated future tasks while simultaneously remembering that we don't estimate in hours.
- woutr_be 7y agoIt saddens me to say, but this is so familiar. Especially working in a big corporate company where they hire scrum masters who just follow the scrum guide.
- matwood 7y agoScrum has a built in self destruct method - the retrospective. With a little maneuvering, the team should be able to remove most of the annoying things about scrum by using the retrospective. Obviously you can't go scorched earth and drop all the annoying bits at once. But, if scrum is really being followed (I know this is also part of the problem), the retro should allow the team to change the process over time.
- 7y ago
- Hitton 7y agoCtrl+z and then kill %1 has yet to fail me. And I'm not talking just vim.
- gustavorg 7y agoThat list is incomplete, at least in windows. You always can do ALT-F4
- aasasd 7y agoIt appears that the first bunch of methods don't account for graphical distributions of Vim, e.g. MacVim―which have a different executable name.
- JdeBP 7y agoI suggest going to https://github.com/hakluke/how-to-exit-vim/issues https://github.com/hakluke/how-to-exit-vim/issues and filing a bug report that sometimes one needs to type in a Scottish accent.
- tambarskjelve 7y agoWARNING: Learning to exit Vim is the number one gateway drug to perpetual configuration of dotfiles and plugins. The truth is that you can never exit Vim. NEVER!
- rsecora 7y agoAs the old joke says[1]. ED(1) Unix Programmer's Manual NAME ed - text editor SYNOPSIS ed [ - ] [ -x ] [ name ] DESCRIPTION Ed is the standard text editor. [1] https://www.gnu.org/fun/jokes/ed-msg.html https://www.gnu.org/fun/jokes/ed-msg.html
- rhinoceraptor 7y agoI've written the following one-liner if ed(1) is unavailable on your system, to emulate its functionality: trap 'echo -e "\n?"' INT; while true; do read; echo "?"; done
- rsecora 7y ago:), Yeah, those were the days!
- konfusinomicon 7y agoWhat's the best way to generate a random string in 2020?? Tell a room full of comp100 students to save and exit vim :)
- CloudXperts 7y agoThank you for this..
- metaxy2 7y agoDo we know if exiting vim is solvable in all cases, or would that require some deeper result like solving P = NP?
- u801e 7y agoNext level: how to exit ed.
- kerkeslager 7y agoAs a senior dev, I wanted to pat myself on the back and say :q But then I realized that the senior dev way is more like: 1. Look it up on Stack Overflow. 2. Send the Stack Oveflow to the intern and tell intern to do it. 3. Reject the PR because it lacks unit tests. 4. Reject the PR because it didn't account for an obscure case that product usually is concerned about. 5. Reject the PR because it there's a simpler way to do it. 6. Pair program with the intern because they're having trouble. 7. Realize that tests are a bit overkill, the obscure case can't happen, and the complexity is because of trying to make it testable and handling the obscure case. 8. Merge a PR that looks suspiciously like what the intern originally submitted. 9. When QA rejects, send back to QA asking for steps to reproduce (har har). 10. When QA sends back steps to reproduce, send back saying you can't reproduce (har har). 11. Sit with QA and see that the bug exists, because they doing something you didn't think of. 12. Fix the bug, merge the code. 13. When the manager asks you to, create the story in Pivotal and push it through all the states (everything so far happened in Slack). 14. Years later, come across the same problem at a different company, and notice someone `:q` in one of the side comments on Stack Overflow, which was there the last time you looked, you didn't notice it.
- _wldu 7y agoWhy is :wq so hard?
- Account123481-x 7y agosome people have way too much free time.
- lenkite 7y ago`ZQ` in normal mode exists VIM with no trouble. 2 keystrokes compared to `:q<Enter>`
- antihero 7y agoI think this is probably far too nice, but what about pkill vim
- MikusR 7y agoThat just types ll vim
- deleted 7y ago[deleted]
- 0x70dd 7y agoEvery time I open vim by accident, I have to restart my computer.
- gowld 7y agoRecent versions of vim have a "quick" exit with mnemonic "q": <Esc> :q!
- a3n 7y agoThe Marvel Universe way: Hulk smash!
- JdeBP 7y agoAs before, I'll see all of those and raise you killing the entire virtual machine in order to exit nano. * https://unix.stackexchange.com/q/412194/5132 https://unix.stackexchange.com/q/412194/5132
- zyxzevn 7y agoDue to the Stockholm Syndrome people started liking VIM...
- jancsika 7y agoWhat about querying how much ram you have and then pasting the letter 'q' that many times plus one into the buffer? Edit: perhaps to speed it up: start with a single 'q', selecting all, yank, and paste. Just script it to repeat until exit happens. No ram query needed.
- longemen3000 7y agoIn Julia slack, when talking about Julia IDEs, this came. The solution : a hardware VIM kill switch https://github.com/caseykneale/VIMKiller/blob/master/README.md https://github.com/caseykneale/VIMKiller/blob/master/README.... I strongly suggest donating the suggested amount to the project
- orang55 7y agoThis is as good of a place as any to mention that I built https://howtoquitvim.com https://howtoquitvim.com a while back if you need a less-sadistic reminder for how to exit Everybody's Favorite Text Editor.
- Diederich 7y agoI first gained access to a UNIXish system in the fall of 1988, which was some SunOS4.x variant I believe. The shell was csh, the editor was vi, and I had no idea what I was doing, nor was there any help in my immediate area to be found. And no, I didn't know about 'man' yet. Somehow I discovered that 'vi' was the way to edit things, but I didn't know how to exit, so trial and error led me to pressing control and z at the same time. Bingo! The shell is back. After some days of building up background suspended vi instances, the system administrator came in and gave me a few pointers.
- kick 7y agoDid you save any?
- Diederich 7y agoYes, I was able to save the file using ZZ rather than :w It's been a long time, but I was probably hung up on not being able to experimentally figure out : commands, where I was able to figure out control-z and ZZ.
- thenewnewguy 7y agoZZ exits vi(m) though?
- Diederich 7y agoYes, it sure does! Well, after 30 years, my memory of the particulars is a bit hazy. (:
- downerending 7y agoSimilar experience, except a ATT 3B2 (and thus no job control). I would have read the man page, but there were none, nor were any books available. I finally just pulled the plug out of the wall. It's not much of an exaggeration to say that I became a lifelong emacs user because the start screen even back then explained how to exit.
- joeblau 7y agoshift + zz Save and out!
- SilasX 7y agoVery clever, but I wish they would put the real way, which, for the record, is :q at the top so that this doesn't annoy people who legitimately google it and have to wade through this.
- artursapek 7y agoBut any of the other methods work just as well
- SilasX 7y agoNot by the metrics "tediousness" and "applicability to later vim usage".
- ryanmcbride 7y agoThis page is well at the bottom of the first results page, and vim tells you how to exit it now when you try things like ctrl+c. I don't think anyone is in danger. https://i.imgur.com/b6dqBiV.png https://i.imgur.com/b6dqBiV.png
- SilasX 7y ago>This page is well at the bottom of the first results page It's at the bottom now, yes, but if this (and copycats) takes off, it won't be. I've seen cases where the search results get so dominated by oh-so-clever parodies that are mixed in with legit answers that you can't tell which is which. >vim tells you how to exit it now when you try things like ctrl+c. Which is great, if that version of vim universally replaced all the others, and every newbie was aware of ctrl-C. For context: in 2011, I tried the project Open Hatch, specifically designed for newbies, and if you followed their tutorial instructions, you could get dumped into a vim terminal with no idea how to get out. >I don't think anyone is in danger. With respect, I'd suggest updating your criteria for making this judgment.
- ryanmcbride 7y agoYou're being a little dramatic
- dreamcompiler 7y agoAfter I invent time travel I'm going to mail my 30-years-ago self a T-shirt that says "Colon Q Bang" on the front and "You're Welcome" on the back. It will save myself much anguish.
- just_myles 7y agoI was able to find how to exit vim fairly easily. I do like this though it's quite funny.
- kerng 7y agoThe one thing I remembered from school about vi was: :q! Figured that would be useful to know in future.
- m0zg 7y agoThe funniest one is the "experienced product manager way" IMO. I've seen plenty of those "experienced project managers" work, and the description is spot on. It's amazing that such impediment to productivity is even tolerated, let alone paid handsome amounts of money for. All while the company _thinks_ they're getting better productivity.
- jrumbut 7y agoI used to believe the most important scientific problems have yet to be solved, but this really was the last great mystery out there.
- rygh 7y agoLearned shift zz after four years of vimming...shame...
- Johnny555 7y agoI'm curious about this one: Don't run this, it could break your computer. :!echo b | sudo tee -a /proc/sysrq-trigger Why would that break my computer? Doesn't that just force a reboot without unmounting disks, or about the same thing that would happen if you pull the power cord (but probably safer, since anything in a hard drive write cache (or in the middle of being written to an SSD) will still be written)
- JdeBP 7y agoOpen issue #46 deals with power cords, and thus: no.
- musicale 7y agoAww, the first thing that came to mind for me was pkill -9 vim, which sadly isn't on the list!
- peterwwillis 7y agoI am upset that they're using signal 9 instead of 15.
- anaphor 7y agoIf you use `kill -9` to exit vim, you might find your terminal in a weird state, because they are most likely using the `atexit` function to reset your termios settings to normal, but that doesn't happen if you `kill -9` it.
- abbadadda 7y agoFavorite vim commands: yy - yank dd - delete and yank O - insert line above o - insert line below GG - go to bottom of file gg - go to top of file Navigation keys == - auto indent code block v - visual mode :%s/find/replace/g :set paste :set number :set nonumber :q - quit :-p I <3 vim + tmux + iTerm2 + tmuxinator
- marc_abonce 7y agoI haven't tried any of these, but wouldn't most of them leave the .swp file there?
- wanderr 7y agoI know this is a joke but my actual preferred way is :cq so that whatever thing decided to open vim doesn't proceed. :)
- svnpenn 7y agoObligatory https://github.com/cabellwg/exit-vim https://github.com/cabellwg/exit-vim
- indigodaddy 7y agoMaybe don’t do the reboot way on Solaris...