How to Exit Vim
github.com
github.com
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.
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.
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.
So, six years later, in 1994, I found myself as the UNIX system administrator for a large (at the time) datacenter at Keesler Regional Medical Center, Keesler AFB, Biloxi Mississippi, where we had quite a number of 3B2s. They were, in fact, the only machines we had that were rated for classified data.
If memory serves, they ran AT&T System V release 3 UNIX.
We also had, among others, DGUX, SCO, AOS/VS, Sun and Vax/VMS servers. Of course each of AOS/VS and VMS had their own, non-UNIX operating systems.
Funny story: we put word out to AETC (Air Education and Training Command) that we needed more 3B2s, and a few months later, some pallets arrived from Homestead Air Force Base, which had been destroyed by hurricane Andrew a couple of years prior. These servers had green and brown smears on them. Clearly they had been submerged by hurricane flooding for some period of time. So we ran a long extension cord out to the parking lot, plugged them in and stepped back. Much to our surprise, several of them actually worked, and later ended up racked in our datacenter.
I remember porting many BSD 4.x utilities to MV/UX. What a learning experience, with the MVs differently-formatted byte vs. word pointers.
The C compiler was really nice, though.
Fun times.
Good times indeed.
SunOS 3.5 on OEM PDP-11s. SunOS4.1.4 on SPARC Stations. SunOS5 (Solaris) on SPARC Stations. DG/UX on a pizza box. SCO on (I think) a 386
There are a number of papers in pure mathematics authored by Doron Zeilberger and Shalosh B Ekhad. (See https://sites.math.rutgers.edu/~zeilberg/ekhad/papers.html for a list. I don't think it's exhaustive)
Shalosh B Ekhad is Zeilberger's computer, which once upon a time was an AT&T 3B1.
In Hebrew, 3 is "shalosh" and 1 is "ekhad".
(The 3B1 isn't actually much like the 3B2, despite the very similar names.)
[0] Well I might write my own emacs-inspired, ruby enabled editor one day, but that's another story.
As to why Control-C doesn't just exit the editor, I suppose it was generally considered to be a bad idea. And in the case of emacs, it might take five or ten minutes to restart. :-)
(It's worth noting also that GNU emacs ran on many platforms, some of which for which Control-C was not any kind of "kill my process" character.)
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!
And where do you get exiting an OS? We don't know... maybe another OS...
Or perhaps it's 5, or 6.
I once caused a near rebellion of vi users when I was running an ISP and symlinked vi to emacs on our shell server because I was sick and tired of it...
C-a does annoyingly conflict with readline's "move to start of line", though.
2. In outer tmux, ssh to some other machine you need to administrate.
3. screen because you need multiple terminal sessions on that machine, or need detachability/reconnectability for some long-running process.
Obviously they could have switched before a general release, but I guess they had gotten used to it.
Just open a scratch file, enter some s-expressions, evaluate them, then kill the buffer.
Never leave your unattended keyboard and screen unlocked.
Acceptable pranks would be things like:
- innocent videos (annoying videos for toddlers etc)
- change Spotify playlist from rock to childrens songs or rickroll or something
- open MS Paint and draw something (those pranks weren't necessarily small, we got three huge monitors side by side on those workstations)
- etc
Unacceptable pranks:
- anything that wasn't possible to revert in a hurry
- anything a customer couldn't see (we were on display :-/ )
At another place I know someone sent a mail to the team from someone elses account that they would bring cake the next day.
I once burned myself by doing what I thought was the obvious thing: leaving a message in a text editor and locking the machine. Turns out for some reason he couldn't unlock it after it had been locked that way and he needed to leave the campus to have IT at the main site unlock it. (When he locked it he always did it by closing the lid instead of through the system menu.)
I did something similar w/ tmux: map the prefix key to C-a and map CapsLock key to Ctrl (never found real use for it). So Ctrl-a (actually CapsLock-a) is very ergonomically pleasant.
(Although this seems to have broken in recent tmux releases on Debian (3.x?) and I haven't looked into yet.)
| 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!
If a user space program can be truly unexitable without restarting (including the possibility of killing it through another shell, of course), then would you consider it to be a bug in the operating system? Seems a reasonable conclusion to me.(read linux/Documentation/admin-guide/sysrq.rst before you try this)
I think gnu screen has the right idea here: ctrl-a.
And you say z is close to control - does that mean you use emacs without shift lock as control?! (I mean sure, still closer than b...).
I know, because I have triple-shift-press mapped to shift lock on my Ergodox. It's... usually better, but sometimes I type a @#$%@#$% swear word when I mean to enter a number.
Presuming Shift Lock means Caps Lock, that and Control are both close to Z on my (Apple) keyboard.
When I used Mac in 2009 to 2012 it depended on the application you were using:
Some used fn+left/fn+right, some used CMD+left/CMD+right and I think ctrl and/or alt + arrow keys were an option too.
ctrl a/ctrl e would work everywhere I think but I didn't use those as they didn't work with shift to select to the start or end of the line.
As a keyboard type of person this was a major part of what drove me away from Mac despite its many advantages :-(
C-a (like in screen) would be even better but as others have pointed out it masks going to the beginning of line which is very common.
C-z is very rarely needed. C-q/C-s would be good candidates also as I don't think I've ever needed flow control in this century nor the last one, for that matter.
E183: User defined commands must start with an uppercase lettercabbrev w <c-r>=(getcmdtype()==':' && getcmdpos()==1 ? 'W' : 'w')<CR>
cabbrev q <c-r>=(getcmdtype()==':' && getcmdpos()==1 ? 'W' : 'q')<CR>
cabbrev q! <c-r>=(getcmdtype()==':' && getcmdpos()==1 ? 'W' : 'q!')<CR>
cabbrev wq <c-r>=(getcmdtype()==':' && getcmdpos()==1 ? 'W' : 'wq')<CR>
- 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.)
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.
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.
I don't touch type, so hjkl, even though I understand the benefits, has never been my preference. Perhaps it's the gamer in me, I've never had trouble using the arrow keys :)
Feel free to correct me If I'm wrong.
For example, Now I know if I need to go to the next instance of the word under the cursror. There's a command for it.
(1) Buying the book Practical Vim from the Pragmatic Programmers, which is aimed at people who kinda-sorta know Vim but don't know much of Vim. I still haven't truly internalized a lot of what I've read, but just understanding the magic of ":find", "." and a slightly greater number of the Ten Thousand Ways to Select has been amazing.
(2) Trying to do as much as possible with "native" commands rather than plugins, then adding a smaller number of considered plugins back in.
(3) Having a real project -- of sorts -- to work on and sticking with Vim for that project. In this case, the project was going through the entire Pragmatic Studio course on Rails 6. (It's good.)
I'm pretty sure these same three steps would work for learning Emacs, too. (Obviously with a good book on Emacs in step 1, not Vim, yes, yes.) But I'm actually pretty happy with Vim.
Also, the proper way to quit MacVim is clearly to select "Force Quit" from the Apple menu.
I learned the 2nd point the hard. The first time I tried vim, I added as much plugin as I can end. In the end, it was a giant mess.
Infuriated by all of the above I found a nice tutorial on how to set up Vim for Go development, used vimtutor, and now I've been able to do non-trivial amount of work while on the train. I actually rather enjoy vim now.
I very much enjoyed the first level. Already quite proficient in vim, I balked at the cost of the full game - but it might well be worth it in your situation.
set nocompatible
source $VIMRUNTIME/mswin.vim
behave mswin
It doesn't really change the command mode if you're used to traditional vim, but you can use shift-arrow keys to select text in VISUAL mode, use CUA commands like C-c, C-x and C-v, etc. Keys like Home, End, C-insert, and S-delete also work.And it was only through attempting to actually install from the Slackware CDs I'd burnt several years earlier that I discovered the scratches on them were unfortunately not just decorative scars.
So: gcc, corrupt. g++, corrupt. Python, corrupt. Perl, corrupt. sed, ...not corrupt. grep, also not corrupt.
I love working on little projects. At one point I noticed that installing specific packages quickly and easily wasn't straightforward because I couldn't see what was already installed.
dialog was among the uncorrupted, and I wondered if I might use this to show installed and uninstalled packages side by side.
That was when I discovered the info pages were also intact, and that sed and grep both had excellent info documentation.
Unfortunately I deliberately gave up working on the project after a few days, as I developed headaches from staring at multiple ~5-6 line (ie, ~480 char) monster regexes over the course of a week or so. (Imagine multiple blocks of modem line noise each 2-4 times longer than http://bash.org/?464385 and you're in the ballpark.)
I do plan to finish that script at some point though (when I regain access to that laptop's HDD). It was only 5 sed commands and 4 grep commands...
I still prefer Emacs because of macros and org-mode, but I no longer fear vi when I'm doing a quick edit, editing a huge file, or on a emacsless new machine.
[1] https://stackoverflow.com/questions/1218390/what-is-your-mos...
Or, you could have just used Rust and SIMD.
My first attempts ended up with my bot buying stock in a clorox brand before posting questionably racist comments to my twitter, but these are minor concerns on the journey.
I'm streaming the process on twitch but please note that donations won't be considered as seed capital for stock assignment
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.
I thought you said quit Vim, not go running back into its warm embrace.
The hardest of the steps ….
Noooooo! Not that! Please not that!
So now we see what Apple was trying to accomplish with the Touch Bar.
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!
Done because I love org mode. What's that? Evil mode? Nah. That's nothin. Ignore it.
I am ethically opposed to cruel and unusual treatment of *Nix users.
You can pry my tiling WM and Tridactyl/qutebrowser away from my cold, dead hands.
Won't help. True addicts know of C-[.
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.
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.
Mostly procrastinating by pretending I was "Being Productive"
Disclaimer: I do most of my coding in Vim but use IDEs every once and a while.
IDEs are a crutch.
The primary focus of an intro engineering course is (usually) about the theory and structure of computing, along with general techniques for writing code.
Learning about various build tools distracts from that focus.
EDIT: Also, you seem to be implying (apologies if I'm wrong) that invoking a compiler from a command line is somehow "better" than using IDE. Why?
Learning development tools like the CLI, IDEs, debuggers, linters, et. al. should be required for a CS degree. I don't think an intro course is the right setting.
I'm in full-agreement that it's a good thing to have a basic understanding of how stuff works, but I'm not sure how enforcing vim over VSCode or Sublime or [insert your favorite editor] necessarily teaches that. It teaches adherence to vim.
I'm of the opinion that programming tools are very personal -- that's why there are so many debates and that's why we'll never have universal agreement. I know my way around the command line and I'll suffer through vim if I have to (it's fine. It's just not my editor of choice), but if I don't have my dotfiles or configurations, I'm not going to be very productive either.
I'm fine with saying, "don't use an IDE in my class, use a text editor" -- but I find it draconian and ridiculous to insist upon a specific text editor.
My preferred Unix editor is the vi family. I wonder whether emacs people are less sympathetic.
I don’t interpret that as the college professor saying this is actually the best way to code, just that forcing students to struggle through it is a learning experience.
Unless the central thrust of the course is supposed to be the mechanics of a particular dated editor, the restriction described seems to be a distraction from rather than an aid to what the students are supposed to be learning.
It doesn't make any more sense than a social science course where the deliverables for most assignments are essays mandating WordPerfect for DOS. Sure, you'll learn something you might not otherwise, but it's a distraction from what you came to the course to learn.
(This is setting aside the argument as to whether Vim is a "dated" editor. Vim is an old editor, to be sure, but forget WordPerfect -- it's not as old as Microsoft Word is!)
I wonder how you feel about age discrimination. Old != bad.
I started using Vim when I was 14; I was the only one in the class who wasn't using an IDE. Vim (perhaps combined with a language server if you're okay with the complexity) runs circles around bloated IDEs like IntelliJ/VSCode. Unix combined with a tiling WM is the best IDE in existence.
The professor in question is likely doing the students a service by showing them the advantages of minimalism and function-over-form over the trend of bundling an OS with every "app". Many students today only feel comfortable using software that saturates their synapses with colors and animations; having to use Vim for a semester forces the good ones to realize that maybe, just maybe, function should come before form. Maybe 10k lines of C or POSIX shell solves a problem better than a VC-backed Electron app.
To continue your analogy, WordPerfect and DOS, unlike Vim, aren't better than today's tools. What would be an improvement is LaTeX/BibTeX for writing essays. Once I realized how much work was automatically done for me--from Chicago-style footnotes/endnotes and auto-generated ToC from headings, the time I spent formatting my papers dropped to zero. I would absolutely incentivize students to use these tools over "modern", bloated word processors.
What I was trying to say was that if minimal solutions run circles around bloated ones thousands of times their size, and when it takes a startup and two funding rounds to develop something that does exactly what tools did three decades ago less efficiently, then maybe Braithwaite was on to something:
> “It’s a curious thing about our industry: not only do we not learn from our mistakes, we also don’t learn from our successes.” -- Keith Braithwaite
This is absolutely unacceptable for students needing different accessibility enabled tools other than vi /vim.
For example, if using an alternative screenreader or a vocally/sound enabled ide or if needing to interact with a text editor via a brail enabled tool that doesn't work with vi, does the student just get failed out? That's a lawsuit waiting to happen.
He might find my vim configuration looks a lot like an IDE with almost 60% of feature of one. (Except compile, I like to use command line for that)
I'm fine if a professor wants to say "we're not using IDEs, we're using text editors in this class and this is why" -- but to dictate the editor would be akin to being told what type of pencil or pen I could use to take hand-written notes.
It reminds me of one of my writing professors who insisted that all papers presented to him be formatted in Arial. Arial is a bad font, so I asked if I could use the metrically identical Helvetica, and he refused. I still submitted my papers in Helvetica anyway and he never noticed.
(I'm not claiming this is a mature response, FWIW, but a core part of my personality naturally pushes back on anyone telling me I can't use something for a wholly arbitrary reason or because they want to enact a ridiculous level of control.)
On the other hand, we had an architect who has since retired that said, if it was up to him, all developers across the campus would use the same programming language, editor, and configuration. Thankfully it was not up to him, and we still have this lovely diversity of opinions and tools that signals it is encouraged for specializations to develop, thus making sure that we are not all replaceable cogs in an exceedingly boring machine.
But the memory of this man's twisted vision remains with me, and it strikes me that the leadership still would seem to prefer if we were in fact fungible units of work-capacity, without any distinctive features or unique characteristics differentiating us from other developers.
IMO if you learned to ensure there was no proof of different tools, you learned an equally valuable lesson; I would mark you down for example if I opened your file and found a bunch of CRLF line endings, or some other similar obvious linting violation that was prevented by an editor configuration you were supposed to have installed during the class. But if you applied enough attention to detail to make sure this was not possible, in a way you got the point (and also for the purposes of the grade, you definitely got the point!)
It was very difficult to follow the guidelines for the exercise and refrain from simply going ahead and solving a problem that I've solved many times before in a way that was familiar to me. In my view it would have taken less time to simply solve the problem than to engage in this seemingly "pointless" exercise, but I do think I understand better after taking the time to convince myself that those other points-of-view have merit and should be taken into account.
Maybe I simply have a case of the old Stockholm syndrome, but between you and GP, I think I'd rather have a more cooperative and acquiescent person on my project team, for the grade. Sounds like a bikeshed argument. First we said the choice didn't matter, that it was less important than the actual programming content of the class; now we're actively combating and making a big stink until someone does some argument dance about it, and convincing happens, so the justification for the specific choice is judged acceptable. (And I guess you've already dug in your heels by this point, and won't be convinced no matter what the reasoning offered.)
What would be your reasons for rejecting vi, specifically? It seems to me that we've actually rejected the idea that editor choice is unimportant; if it was so trivial and doesn't matter which editor, we probably wouldn't be fighting about it, nobody would mind the seemingly arbitrary decision. Nobody would ask for sound reasons to justify.
If the point of the course had been to learn vi, or the teacher had given a compelling reason for why specifically vi, rather than less specific instructions, then I might have accepted that if their reasons were good enough.
I'm really happy my algorithms professor let me use Makefiles and vim even though the standard tool at the university was (blegh!!!) visual studio.
But learning Vim isn't related to learning how to program. In that context, it's a pointless distraction.
Be honest -- when was the last time that you or anyone you know had a programming assignment at work and came back to scrum a week later saying, "I'd have finished this, but navigating around my editor just took up too much time?" >95% of programming is going to be bottle-necked by the speed you think, not the speed at which you can edit text.
So it's like forcing all of your students to learn Dvorak, or to submit all their written work in cursive. Undoubtedly a few students will thank you for it at the end of the class because some people do get real value out of learning those skills -- but just as many of them will say you wasted their time, and they'll be right. I write in cursive too; it's an objectively faster, more pleasant way to take handwritten notes. That doesn't mean that learning cursive has anything to do with learning to write books.
To any professors on HN reading this: if you're teaching a programming class, please teach programming. Because if students just wanted to learn something new, or to be forced to struggle with something outside of their comfort zones, there are a lot of cheaper ways than college they could do that.
Even with that goal -- a programming professor can't come up with any outside-the-box assignments more related to their subject than "learn Vim"? I can't fathom that kind of lack of creativity in a field this broad.
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.
[0] https://www.phoronix.com/scan.php?page=news_item&px=Fedora-W...
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)
If you have configured an editor, hopefully you already know how to quit.
Another option would be to fail and prompt the user to configure an editor preference. That wouldn't be much different (to me) than what it does now.
Something along the lines of "Type :qa and press <Enter> to exit Vim" would probably do it...
It's not a bug, it's a feature.
Type :qa! and press <Enter> to abandon all changes and exit VimIf you wanted to also help slightly more modern users who are used to CUA conventions from GUIs, you would have the [F1] key bring up some form of help screen, which said something like "Get out of Vim: Use :qa!" at the top.
If you wanted to also help silghtly more modern users who are used to discoverable-UI conventions from mobile apps, you would have it so shaking your device brings up some form of chat bot, which would suggest asking it how to quit Vim.
And one of these ideas is not like the others.
Clippy, please tell everyone how Lio's and my if-only-VIM-did-this ideas are different to Kerrick's idea.
The best thing that can happen to a beginner is they continue being frustrated with vim, quit it before they get in too deep, and just use shitty idees like the rest of us trash.
It helps that VScode is also my editor of choice in general.
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.
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.
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.
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.
Started learning Rails, drank the Kool-Aid, switched to VIM. I don't use VIM for development at my day-job, mostly just key-bindings in Intellij/VS Code, however, the amount of time saved has been worth the effort, and no RSI (also thankfully am able to use the fantastic track-pad on mac and a trackball for anything else).
Lately I've been feeling the pull to learn Emacs after learning about ORG-Mode and the extensibility of the software... unfortunately, the time investment here is likely to have no real benefit in my (current) work as a Java dev. Sigh, time to browse the who's hiring thread.
But Vim (and emacs) solves the repetitive motion problem by providing several means of readily repeating commands.
Most people seem to both type and use their mouse much more slowly than I do. And they also don't often have to (or want to), e.g. cleanup thousands of rows in an Excel worksheet, or have to repeat some kind of action in an app or web app dozens of times.
But I hate using my mouse generally. There are very few times where I want to use a mouse and having to use one, instead of being able to use the keyboard, is endlessly frustrating.
Thankfully, there are several great 'vi-style' browser extensions and there's even [Vimac](https://vimacapp.com/) for MacOS, tho I haven't tried the latter yet.
1: https://vimhelp.org/pattern.txt.html#gd
Maybe I'm not thinking straight because of the sickness, but I think `ddp` from the line above does the same thing with one fewer keystroke.
(Works if register contents after the operation do not matter to you; I don’t think the OP knows or cares what registers are)
> My husband uses vim. It’s why I married him. But I just found out his email client is emacs. I don’t know how I feel about this.
https://github.com/hakluke/how-to-exit-vim/blob/master/READM...
As to why shutdown: cultural thing in the end. I was raised with the idea that wasting is bad (and objectively speaking it's very hard to argue with that) so if I don't need the machine running after I'm done with it, I just can't stand the idea of the thing using energy literally for nothing.
(As I finished writing this, and was about to type ^[fG to submit this reply, I couldn't help but smile a bit)
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 trap 'echo -e "\n?"' INT; while true; do read; echo "?"; done :q
at the top so that this doesn't annoy people who legitimately google it and have to wade through this.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.
Sarcasm aside, I fully agree with you.
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.
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.
: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.
:!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 -9Most other constructions can backfire in some unexpected way.
* https://mywiki.wooledge.org/ProcessManagement#The_risk_of_pa...
What a day!
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.
Also, your reply is the kindest comment I've ever seen on HN.
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.
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 ...
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.
(since then I implemented the preemptive way: never ever try to open it again)
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.
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.
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.
:x
which effectively does an :wq if there have been changes but is one character less.
$ while true; do curl 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?
Almost as important a problem in Computer Science as P!=:WQ.
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.
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.
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.
What I currently see is that our scrum master has sold the business on the agile way, so if a developer complains about it, there's something wrong with the developer. It's probably just a bad scrum master, but I've met multiple of those.
I showed up long after they implemented it, so I'm not sure how they got there, but the most well-functioning Scrum team I ever participated in had effectively designated the nominal Scrum Master as a BDFL. The retrospective then became a shorter sort of town hall meeting where everyone aired their opinions, but, since we had a BDFL, we had no need to burn energy on consensus-building. Sadly, things quickly went to hell after she left and the team reverted to a more traditional consensus-oriented approach.
13. Ask the team what we can do to make sure we don't have to miss the deadline
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.
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.
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)
'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.
(That and the Rogue navigation keys.)
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
Tell a room full of comp100 students to save and exit vim :)
They should add the script kiddie way: `sudo rm -rf /` ^^
Yep, `ps | grep` is a common and useful idiom!
pkill vimThe best advice I ever received was, you next open emacs and leave the session running the rest of your life.
You can also just suspend it (ctrl+Z), and resume it with fg.
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. :)
:q!
your memory, not the computer's
The test driven development way
:echom test_null_list()
And it works. Just checked.
<Esc> :q!or the French way - ZZ
Why the French way? I don't get it and I am very curious :-)
[0] https://unix.stackexchange.com/questions/93144/exit-vim-more...
Only if you're American. Otherwise: "zed-zed". :)
HOW DID I NOT KNOW THIS
took me a while to get it
:q!
Figured that would be useful to know in future.
Hulk smash!
shift + zz
Save and out!;-)
Also that we nerds enjoy making jokes about it instead of fixing it is the reason we don't get invited to parties.